Skip to content

Commit

Permalink
Support for hg if the github repository is pulled using hg git extension
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-unity committed Jul 21, 2016
1 parent 597d468 commit ca982b9
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions make_version.py
Expand Up @@ -9,14 +9,24 @@
def main (argv):
root = os.path.abspath(os.path.dirname(__file__))
git_path = os.path.join(root, '.git')
hg_path = os.path.join(root, '.hg')

if not os.path.exists(git_path):
return

try:
txt = subprocess.check_output(['git', 'describe', '--long', '--always', '--dirty']).strip()
except:
return
if os.path.exists(git_path):
try:
txt = subprocess.check_output(['git', 'describe', '--long', '--always', '--dirty']).strip()
except:
print "Failed to retrieve version from git"
return 1
elif os.path.exists(hg_path):
try:
branch = subprocess.check_output(['hg', 'log', '-r', '.', '--template', '{latesttag}']).strip()
txt = subprocess.check_output(['git', '--git-dir=.hg/git', 'describe', '--long', '--always', branch]).strip()
except:
print "Failed to retrieve version from hg"
return 1
else:
print "Unknown version control system."
return 1

# convert the git describe text to a version
pts = txt.split('-', 2)
Expand All @@ -43,6 +53,7 @@ def main (argv):
line = '%s,%s,%s' % (pts[0], tag_vers, pts[2])
fh.write(line)
fh.write('\n')
return 0

if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))

0 comments on commit ca982b9

Please sign in to comment.