OpenCompass/opencompass/utils/git.py
2023-07-05 03:15:31 +00:00

14 lines
417 B
Python

import subprocess
def get_git_root() -> str:
cmd = ['git', 'rev-parse', '--show-toplevel']
result = subprocess.run(cmd, stdout=subprocess.PIPE, check=True)
return result.stdout.decode('utf-8').strip()
def get_latest_commit(branch: str) -> str:
cmd = ['git', 'rev-parse', branch]
result = subprocess.run(cmd, stdout=subprocess.PIPE, check=True)
return result.stdout.decode('utf-8').strip()