| 381 | |
| 382 | |
| 383 | def 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 | |
| 403 | def is_dist_avail_and_initialized(): |