Unverified Commit 53b54f5f authored by Vitaly Polonetsky's avatar Vitaly Polonetsky Committed by GitHub
Browse files

feat(git): guess main branch name also from remotes (#10158)


Co-authored-by: default avatarMarc Cornellà <hello@mcornella.com>
parent 21b385e7
...@@ -32,10 +32,10 @@ function work_in_progress() { ...@@ -32,10 +32,10 @@ function work_in_progress() {
# Check if main exists and use instead of master # Check if main exists and use instead of master
function git_main_branch() { function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return command git rev-parse --git-dir &>/dev/null || return
local branch local ref
for branch in main trunk; do for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk}; do
if command git show-ref -q --verify refs/heads/$branch; then if command git show-ref -q --verify $ref; then
echo $branch echo ${ref:t}
return return
fi fi
done done
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment