Skip to content

Commit

Permalink
Fix get main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Mar 2, 2022
1 parent e0f650a commit 5409b55
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion c2cciutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,17 @@ def get_branch(branch: Optional[str]) -> str:
Return the branch name
"""

return branch or (
if branch is not None:
return branch
branch = (
subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], check=True, stdout=subprocess.PIPE)
.stdout.decode()
.strip()
)
if branch == "HEAD":
branch = os.environ.get("GITHUB_HEAD_REF", "master")
assert branch is not None
return branch


def get_based_on_master(
Expand Down

0 comments on commit 5409b55

Please sign in to comment.