Skip to content
Open
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
10 changes: 3 additions & 7 deletions update-pr-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ check_env_var() {

# Check if a branch already has the squash commit merged (squash-merge mode only)
# Requires SQUASH_COMMIT ref to be set via git update-ref
#
# Note: This uses local branch refs. The caller must ensure both branches
# exist locally before calling (e.g., via git checkout).
has_squash_commit() {
local BRANCH="$1"
local BASE="$2"
Expand All @@ -78,12 +75,11 @@ update_direct_target() {
local BRANCH="$1"
local BASE_BRANCH="$2"

# Checkout first to ensure the local branch exists (created from origin if
# needed). This allows has_squash_commit to compare local refs, which matters
# for testing where the script may run multiple times in the same repo.
log_cmd git checkout "$BRANCH"

if has_squash_commit "$BRANCH" "$TARGET_BRANCH"; then
# The target branch is never checked out, so it has no local ref, only the
# remote-tracking one; a bare $TARGET_BRANCH would not resolve.
if has_squash_commit "$BRANCH" "origin/$TARGET_BRANCH"; then
echo "✓ $BRANCH already up-to-date; skipping"
return 0
fi
Expand Down
Loading