Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 054f4cd

Browse files
feat(git): add remote symbolic-ref detection for base branch
1 parent aed1846 commit 054f4cd

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

focal/wip_context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ def resolve_base_branch(target: str | None) -> str:
115115
sys.exit(f"Error: Specified base branch '{target}' does not exist.")
116116
return target
117117

118+
# Dynamically query the default branch of the remote
119+
code, out = run_git(["symbolic-ref", "refs/remotes/origin/HEAD"], check=False)
120+
if code == 0:
121+
return out.split("/")[-1].strip()
122+
118123
fallbacks = ["main", "master", "develop"]
119124
for branch in fallbacks:
120125
code, _ = run_git(["rev-parse", "--verify", branch], check=False)

0 commit comments

Comments
 (0)