Skip to content

Commit

Permalink
fixing bug in getting commit hash while out of repository dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmejia committed Sep 30, 2024
1 parent cb47057 commit a370045
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/lvmdrp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ 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:
return subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip()
cwd = os.getcwd()
os.chdir(pathlib.Path(__file__).parent)
commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip()
os.chdir(cwd)
return commit_hash

def get_git_revision_short_hash() -> str:
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
cwd = os.getcwd()
os.chdir(pathlib.Path(__file__).parent)
commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
os.chdir(cwd)
return commit_hash


DRP_COMMIT = get_git_revision_short_hash()

0 comments on commit a370045

Please sign in to comment.