MCPcopy Create free account
hub / github.com/cjrd/self-supervised-pretraining / get_git_hash

Function get_git_hash

OpenSelfSup/setup.py:26–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24
25
26def get_git_hash():
27
28 def _minimal_ext_cmd(cmd):
29 # construct minimal environment
30 env = {}
31 for k in ['SYSTEMROOT', 'PATH', 'HOME']:
32 v = os.environ.get(k)
33 if v is not None:
34 env[k] = v
35 # LANGUAGE is used on win32
36 env['LANGUAGE'] = 'C'
37 env['LANG'] = 'C'
38 env['LC_ALL'] = 'C'
39 out = subprocess.Popen(
40 cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
41 return out
42
43 try:
44 out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
45 sha = out.strip().decode('ascii')
46 except OSError:
47 sha = 'unknown'
48
49 return sha
50
51
52def get_hash():

Callers 1

get_hashFunction · 0.85

Calls 1

_minimal_ext_cmdFunction · 0.85

Tested by

no test coverage detected