Skip to content

Record the repository's default branch as the merge base outside pull requests - #261

Merged
sauliusbc merged 1 commit into
mainfrom
merge-base-default-branch
Oct 20, 2026
Merged

sauliusbc merged 1 commit into
mainfrom
merge-base-default-branch

Conversation

@sauliusbc

@sauliusbc sauliusbc commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Outside pull requests --merge-base-branch-name was hardcoded to main, even in repositories with no main branch. It is now the repository's default branch from the event payload, falling back to main.

A repository whose default branch is trunk, with no main:

Event Branch run Merge base before After Verified
workflow_dispatch trunk ❌ main ✅ trunk ✅ live run: payload has repository.default_branch
workflow_dispatch topic ❌ main ✅ trunk same payload field
workflow_dispatch → workflow_call trunk ❌ main ✅ trunk ✅ live run: the called workflow gets the caller's payload
push trunk ❌ main ✅ trunk ✅ live run: payload has repository.default_branch
pull_request topic → trunk ✅ trunk ✅ trunk unchanged (PR base)

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Mayhem Automated Code Testing Report

❗ 1 Defects Found

CWE Severity Defect Description
7.1 Improper Input Validation The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.

Testing details found at https://app.mayhem.security/forallsecure/mcode-action/mayhemit/73

@ethan42 ethan42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rebase carefully

… requests

The merge base branch was hardcoded to "main" for every event other than a
pull request, so runs in a repository whose default branch is named
differently recorded a branch that may not exist. Use the event payload's
repository.default_branch, keeping "main" only when the payload has no
repository. The event payload is now typed (src/github.ts). dist/ rebuilt
from the locked dependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sauliusbc
sauliusbc force-pushed the merge-base-default-branch branch from f065078 to f45a148 Compare October 20, 2026 10:09
@sauliusbc
sauliusbc merged commit dcf5a19 into main Oct 20, 2026
9 checks passed
@sauliusbc
sauliusbc deleted the merge-base-default-branch branch October 20, 2026 11: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.

2 participants