Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions scripts/pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ await_merge() { # await_merge <branch>: waits up to 40 minutes
die "the pull request of $1 is not merged after 40 minutes: gh pr checks $1"
}

# Back on main after the merge; in a worktree main is checked out elsewhere,
# so this continues detached on origin/main.
# Back on main after the merge, when the local main can simply follow
# origin/main. Otherwise (main is checked out in another worktree, or holds
# commits origin/main lacks) this continues detached on origin/main and leaves
# the local main as it is.
leave_branch() {
git fetch --quiet origin main
if git switch --quiet main 2>/dev/null; then
git pull --quiet --ff-only
if git merge-base --is-ancestor main origin/main 2>/dev/null && git switch --quiet main 2>/dev/null; then
git merge --quiet --ff-only origin/main
else
git switch --quiet --detach origin/main
echo "==> continuing detached on origin/main; the local main is left as it is"
fi
git branch -D "$1" >/dev/null 2>&1 || true
}
Expand Down
10 changes: 10 additions & 0 deletions scripts/test_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ git -C "$repo" switch -q main
git -C "$repo" commit -q --allow-empty -m "local only"
check "release: refused on a main ahead of origin" 1 release patch x VERSION release.yml VERSION

setup VERSION 1.2.3
ci_tag v1.2.4
git -C "$repo" switch -q main
git -C "$repo" commit -q --allow-empty -m "unpushed work on the local main"
local_main=$(git -C "$repo" rev-parse main)
git -C "$repo" switch -q feat
check "release: a local main with unpushed commits does not stop it" 0 release patch x VERSION release.yml VERSION
expect "release: the local main is left as it was" test "$(git -C "$repo" rev-parse main)" = "$local_main"
expect "release: continues detached on origin/main" test "$(git -C "$repo" rev-parse --abbrev-ref HEAD)" = HEAD

setup VERSION 1.2.3
ci_tag v2.0.0
check "release: major" 0 release major x VERSION release.yml VERSION
Expand Down
Loading