Skip to content

fix: use CIRCLE_SHA1 for checkout to survive squash-merge branch deletion#8

Merged
jonbaldie merged 1 commit into
mainfrom
fix/circleci-post-merge-branch
Apr 26, 2026
Merged

fix: use CIRCLE_SHA1 for checkout to survive squash-merge branch deletion#8
jonbaldie merged 1 commit into
mainfrom
fix/circleci-post-merge-branch

Conversation

@jonbaldie

Copy link
Copy Markdown
Owner

Problem

After a squash-merge, CircleCI triggers a post-merge build where CIRCLE_BRANCH is set to the now-deleted source branch. The current config does:

git clone -b ${CIRCLE_BRANCH} ...

This fails with fatal: Remote branch <branch> not found because squash-merging deletes the source branch.

Every squash-merge has been silently causing a post-merge CI failure on main.

Fix

Switch from branch-based clone to SHA-based checkout:

git clone https://github.com/jonbaldie/queue.git && cd queue && git checkout ${CIRCLE_SHA1}

CIRCLE_SHA1 is the exact commit SHA CircleCI is testing — always exists regardless of branch lifecycle.

…tion

After a squash-merge, CircleCI triggers a build where CIRCLE_BRANCH is
the now-deleted source branch. git clone -b <branch> then fails with
'branch not found'. Switching to clone default + git checkout SHA1
which always exists regardless of branch lifecycle.
@jonbaldie
jonbaldie merged commit b763cee into main Apr 26, 2026
1 check passed
@jonbaldie
jonbaldie deleted the fix/circleci-post-merge-branch branch April 26, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant