get_github_rev.py 475 B

123456789101112131415
  1. import subprocess
  2. # Get revision used for constructing github URLs
  3. def get_github_rev():
  4. path = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip().decode('utf-8')
  5. try:
  6. tag = subprocess.check_output(['git', 'describe', '--exact-match']).strip().decode('utf-8')
  7. except subprocess.CalledProcessError:
  8. tag = None
  9. print('Git commit ID: ', path)
  10. if tag:
  11. print('Git tag: ', tag)
  12. return tag
  13. return path