| 246 | |
| 247 | |
| 248 | def get_sha(): |
| 249 | cwd = os.path.dirname(os.path.abspath(__file__)) |
| 250 | |
| 251 | def _run(command): |
| 252 | return subprocess.check_output(command, cwd=cwd).decode('ascii').strip() |
| 253 | sha = 'N/A' |
| 254 | diff = "clean" |
| 255 | branch = 'N/A' |
| 256 | try: |
| 257 | sha = _run(['git', 'rev-parse', 'HEAD']) |
| 258 | subprocess.check_output(['git', 'diff'], cwd=cwd) |
| 259 | diff = _run(['git', 'diff-index', 'HEAD']) |
| 260 | diff = "has uncommited changes" if diff else "clean" |
| 261 | branch = _run(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) |
| 262 | except Exception: |
| 263 | pass |
| 264 | message = f"sha: {sha}, status: {diff}, branch: {branch}" |
| 265 | return message |
| 266 | |
| 267 | |
| 268 | def collate_fn(batch): |