Skip to content

Commit

Permalink
fixing mismatch in short hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmejia committed Oct 1, 2024
1 parent 42a4c27 commit e94be25
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions python/lvmdrp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setup_paths(release: str = 'sdsswork', replant: bool = False):


# NOTE: taken from https://stackoverflow.com/questions/14989858/get-the-current-git-hash-in-a-python-script
def get_git_revision_hash() -> str:
def get_git_revision_hash(trim_to=8) -> str:
cwd = os.getcwd()
os.chdir(pathlib.Path(__file__).parent)
try:
Expand All @@ -48,18 +48,7 @@ def get_git_revision_hash() -> str:
log.warning(f"error {e.returncode} while getting commit hash: {e.output}, setting hash to None")
return
os.chdir(cwd)
return commit_hash

def get_git_revision_short_hash() -> str:
cwd = os.getcwd()
os.chdir(pathlib.Path(__file__).parent)
try:
commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
except subprocess.CalledProcessError as e:
log.warning(f"error {e.returncode} while getting commit hash: {e.output}, setting hash to None")
return
os.chdir(cwd)
return commit_hash
return commit_hash[:trim_to]


DRP_COMMIT = get_git_revision_short_hash()
DRP_COMMIT = get_git_revision_hash()

0 comments on commit e94be25

Please sign in to comment.