Skip to content

Commit

Permalink
q&d fix for graceful failure
Browse files Browse the repository at this point in the history
  • Loading branch information
d2f4d131d9eac6cc27e3d6245ab1476b committed Mar 26, 2024
1 parent 4a10fdf commit 6f6eb1e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/irrevolutions/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,22 @@ def format(self, record):
import subprocess

# Get the current Git branch
branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip().decode("utf-8")
def get_current_branch():
try:
# Get the current Git branch
branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], stderr=subprocess.PIPE).strip().decode("utf-8")
commit_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode("utf-8")
return branch, commit_hash
except subprocess.CalledProcessError as e:
# Handle the error
error_message = e.stderr.decode("utf-8").strip()
print(f"Error occurred while getting the current branch: {error_message}")
return 'unknown', 'unknown'

# Get the current branch
branch, commit_hash = get_current_branch()

# Get the current Git commit hash
commit_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode("utf-8")

code_info = {
"branch": branch,
Expand Down

0 comments on commit 6f6eb1e

Please sign in to comment.