Skip to content

fix(automerge): use a repo-allowed merge method; surface enable_auto_merge errors - #110

Merged
toufali merged 3 commits into
mainfrom
fix/automerge-merge-method
Jul 30, 2026
Merged

fix(automerge): use a repo-allowed merge method; surface enable_auto_merge errors#110
toufali merged 3 commits into
mainfrom
fix/automerge-merge-method

Conversation

@toufali

@toufali toufali commented Jul 30, 2026

Copy link
Copy Markdown
Member

Fixes #109.

Problem

enable_auto_merge hardcodes mergeMethod: SQUASH, which fails on repos that disable squash merges (e.g. mozilla/fxa, merge-commit-only). approve_and_merge ignores the returned error and logs Auto-merge enabled regardless, so PRs are approved but never auto-merge — silently.

Fix

  • github_utils.py: add _allowed_merge_method() — pick a method the repo permits (prefer SQUASH, else MERGE, else REBASE) and pass it to the mutation as a variable.
  • automerge_dependabot.py: approve_and_merge now checks enable_auto_merge's return and raises SkipPR(...) with the real error, so a failure is reported honestly instead of logged as success.

Testing

Not run in the Actions context (needs app creds). Both files py_compile clean. Behavior on squash-enabled repos is unchanged (SQUASH is still preferred); merge-commit-only repos now fall back to MERGE.

🤖 Generated with Claude Code

toufali and others added 2 commits July 29, 2026 19:40
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…alse success

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a silent auto-merge failure mode in BLEnder’s Dependabot automerge workflow by selecting a merge method that the target repository actually allows and by surfacing GraphQL auto-merge enablement errors instead of logging success.

Changes:

  • Add merge-method selection logic that prefers SQUASH but falls back to MERGE or REBASE based on repo settings.
  • Update the GraphQL mutation to accept the merge method as a variable and pass the selected method.
  • Propagate enable_auto_merge failures up to the main loop by raising SkipPR with the actual error message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/github_utils.py Select an allowed merge method from repo settings and pass it into the GraphQL auto-merge mutation; continue returning a string error on failure.
scripts/automerge_dependabot.py Treat enable_auto_merge failures as actionable by raising SkipPR with the returned error instead of proceeding as if auto-merge was enabled.

Comment thread scripts/github_utils.py
Comment thread scripts/automerge_dependabot.py
…_merge error path

Addresses review feedback on #110: unit tests for merge-method selection
(squash disabled -> MERGE) and approve_and_merge raising SkipPR when
enable_auto_merge returns an error.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@toufali
toufali merged commit 6e59cf1 into main Jul 30, 2026
9 checks passed
@toufali
toufali deleted the fix/automerge-merge-method branch July 30, 2026 18:49
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.

fix(automerge): use a repo-allowed merge method; surface enable_auto_merge errors

2 participants