def get_git_changeset():
 repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 git_log = subprocess.Popen(u'git log --pretty=format:%ct --quiet -1 HEAD', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=repo_dir, universal_newlines=True)
 timestamp = git_log.communicate()[0]
 try:
  timestamp = datetime.datetime.utcfromtimestamp(int(timestamp))
 except ValueError:
  return None
 return timestamp.strftime(u'%Y%m%d%H%M%S')

def get_git_changeset ( ) : repo_dir = os . path . dirname ( os . path . dirname ( os . path . abspath ( __file__ ) ) ) git_log = subprocess . Popen ( u'git log --pretty=format:%ct --quiet -1 HEAD' , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = True , cwd = repo_dir , universal_newlines = True ) timestamp = git_log . communicate ( ) [ 0 ] try : timestamp = datetime . datetime . utcfromtimestamp ( int ( timestamp ) ) except ValueError : return None return timestamp . strftime ( u'%Y%m%d%H%M%S' )
returns a numeric identifier of the latest git changeset .