Add base-branch detection

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-09-28 13:02:31 +02:00
parent 3e907e91f3
commit 82f778ccf4
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -15,6 +15,13 @@ for remote in $(git remote -v | awk '{print $1}' | sort | uniq); do
done
[[ -z ${jump_branch} ]] || {
[[ ${jump_branch} != "-d" ]] || {
step "Detecting base branch to jump to..."
known_bases=($(git branch | grep -Eo '(develop|main|master)$'))
[ ${#known_bases[@]} -eq 1 ] || fail "Expected exactly one potential base branch, got ${#known_bases[@]}: ${known_bases[@]}"
jump_branch=${known_bases[0]}
}
step "Switching to branch ${jump_branch}"
git switch "${jump_branch}"
}