Skip to content

fix(git-changed): accept a bare $GITHUB_BASE_REF branch before the default branch - #102

Merged
pyramation merged 1 commit into
mainfrom
fix/git-changed-bare-base-ref
Aug 3, 2026
Merged

fix(git-changed): accept a bare $GITHUB_BASE_REF branch before the default branch#102
pyramation merged 1 commit into
mainfrom
fix/git-changed-bare-base-ref

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Found while migrating @pgsql/lint onto this package: its own implementation resolved $GITHUB_BASE_REF one step further than git-changed does, and that step is worth keeping.

-if (verified(`origin/${prBase}`)) return `origin/${prBase}`;
-// else fall through to the default branch
+for (const ref of [`origin/${prBase}`, prBase]) {
+  if (verified(ref)) return ref;
+}

origin/ still comes first — in Actions only the remote ref is fetched, and a stale local branch of the same name would diff against the wrong commit. But when the remote ref is missing, a local branch of that name is a far better answer than the repository default branch: someone running the tool outside CI with GITHUB_BASE_REF exported, or a job that checked out the base branch by name, gets the base they actually asked for instead of silently being diffed against main.

Falling through to the default branch only when neither exists. Unchanged: never return a ref that doesn't resolve.

Adds a test for the new fall-through ($GITHUB_BASE_REF=release/9.9 → default branch); the existing "remote ref missing" test now documents the bare-branch hit rather than the fall-through, with the same assertion.

Needs a publish before the @pgsql/lint migration can point at it — that PR's suite asserts this exact case.

Link to Devin session: https://app.devin.ai/sessions/e84444b40007481e9de0285d8b5340b6
Requested by: @pyramation

@pyramation pyramation self-assigned this Aug 3, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit 7d80848 into main Aug 3, 2026
55 checks passed
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