MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / get_sha

Function get_sha

utils.py:383–400  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

381
382
383def get_sha():
384 cwd = os.path.dirname(os.path.abspath(__file__))
385
386 def _run(command):
387 return subprocess.check_output(command, cwd=cwd).decode('ascii').strip()
388 sha = 'N/A'
389 diff = "clean"
390 branch = 'N/A'
391 try:
392 sha = _run(['git', 'rev-parse', 'HEAD'])
393 subprocess.check_output(['git', 'diff'], cwd=cwd)
394 diff = _run(['git', 'diff-index', 'HEAD'])
395 diff = "has uncommited changes" if diff else "clean"
396 branch = _run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
397 except Exception:
398 pass
399 message = f"sha: {sha}, status: {diff}, branch: {branch}"
400 return message
401
402
403def is_dist_avail_and_initialized():

Callers

nothing calls this directly

Calls 1

_runFunction · 0.85

Tested by

no test coverage detected