Login

Use git log to give your app a revision

Author:
peterbe
Posted:
October 30, 2009
Language:
Python
Version:
1.1
Score:
6 (after 6 ratings)

Put that stuff in your settings.py Then you can use the git log last date to make that your "revision number" assuming you don't use regular version release numbers. With it you can do something like:

<div id="footer">
&copy; My Company 
&mdash; The Super App (revision {{ GIT_REVISION_DATE }})
 </div>

See if you like it

1
2
3
4
5
6
7
8
import subprocess
_proc = subprocess.Popen('git log --no-color -n 1 --date=iso',
                         shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
    GIT_REVISION_DATE = [x.split('Date:')[1].split('+')[0].strip() for x in
                         _proc.communicate()[0].splitlines() if x.startswith('Date:')][0]
except IndexError:
    GIT_REVISION_DATE = 'unknown'

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 3 months, 1 week ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 3 months, 2 weeks ago
  3. Serializer factory with Django Rest Framework by julio 10 months, 1 week ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 11 months ago
  5. Help text hyperlinks by sa2812 11 months, 3 weeks ago

Comments

feresp (on October 30, 2009):

Is it only for Linux machines? Thanks...

#

palobo (on November 1, 2009):

Nice and simple idea. Since I prefer mercurial a slight modification will be needed though.

Thanks.

#

Please login first before commenting.