Skip to content

Commit

Permalink
Use git tags for version
Browse files Browse the repository at this point in the history
  • Loading branch information
artynusov committed Jan 6, 2014
1 parent bb317b5 commit f3c3f25
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 0 additions & 2 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<string>MacTimeLog</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.3-alpha</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>DTCompiler</key>
Expand Down
24 changes: 17 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,28 @@
from plistlib import Plist


def generate_plist(plist_file):
"""Read plist from file and set CFBundleVersion to HEAD commit hash"""
def git(*args):
result = None
try:
commit_hash = subprocess.check_output(
['git', 'rev-parse', '--short', 'HEAD']).strip()
result = subprocess.check_output(args).strip()
except Exception, e:
print >> sys.stderr, ('Unable to get git commit hash for '
'CFBundleVersion {0}'.format(e))
commit_hash = 'none'
print >> sys.stderr, ('Unable to run git: {0}'.format(e))
return result



def generate_plist(plist_file):
"""Read plist from file and set CFBundleVersion to HEAD commit hash"""

version = git('git', 'describe', '--abbrev=0', '--tags')
commit_hash = git('git', 'rev-parse', '--short', 'HEAD')

if version is None or commit_hash is None:
sys.exit(-1)

plist = Plist.fromFile(plist_file)
plist.update(dict(
CFBundleShortVersionString=version,
CFBundleVersion=commit_hash,
))
return plist
Expand Down

0 comments on commit f3c3f25

Please sign in to comment.