def pkg_commit_hash(pkg_path):
 pth = os.path.join(pkg_path, COMMIT_INFO_FNAME)
 if (not os.path.isfile(pth)):
  raise IOError((u'Missing commit info file %s' % pth))
 cfg_parser = ConfigParser()
 cfg_parser.read(pth)
 archive_subst = cfg_parser.get(u'commit hash', u'archive_subst_hash')
 if (not archive_subst.startswith(u'$Format')):
  return (u'archive substitution', archive_subst)
 install_subst = cfg_parser.get(u'commit hash', u'install_hash')
 if (install_subst != u''):
  return (u'installation', install_subst)
 proc = subprocess.Popen(u'git rev-parse --short HEAD', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=pkg_path, shell=True)
 (repo_commit, _) = proc.communicate()
 if repo_commit:
  if PY3:
   repo_commit = repo_commit.decode()
  return (u'repository', repo_commit.strip())
 return (u'(none found)', u'<not found>')

def pkg_commit_hash ( pkg_path ) : pth = os . path . join ( pkg_path , COMMIT_INFO_FNAME ) if ( not os . path . isfile ( pth ) ) : raise IOError ( ( u'Missing commit info file %s' % pth ) ) cfg_parser = ConfigParser ( ) cfg_parser . read ( pth ) archive_subst = cfg_parser . get ( u'commit hash' , u'archive_subst_hash' ) if ( not archive_subst . startswith ( u'$Format' ) ) : return ( u'archive substitution' , archive_subst ) install_subst = cfg_parser . get ( u'commit hash' , u'install_hash' ) if ( install_subst != u'' ) : return ( u'installation' , install_subst ) proc = subprocess . Popen ( u'git rev-parse --short HEAD' , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = pkg_path , shell = True ) ( repo_commit , _ ) = proc . communicate ( ) if repo_commit : if PY3 : repo_commit = repo_commit . decode ( ) return ( u'repository' , repo_commit . strip ( ) ) return ( u'(none found)' , u'<not found>' )
get short form of commit hash given directory pkg_path we get the commit hash from : * ipython .