From 82f778ccf4844c870360c1df3a82a7bf535bdb62 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 28 Sep 2022 13:02:31 +0200 Subject: [PATCH] Add base-branch detection Signed-off-by: Knut Ahlers --- bin/git-ps | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/git-ps b/bin/git-ps index 5a30646..0137656 100755 --- a/bin/git-ps +++ b/bin/git-ps @@ -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}" }