Skip to content

fix: prevent PR targeting same branch and duplicated prefix#244

Merged
rubenmarcus merged 2 commits intomainfrom
fix/pr-creation-same-branch
Feb 23, 2026
Merged

fix: prevent PR targeting same branch and duplicated prefix#244
rubenmarcus merged 2 commits intomainfrom
fix/pr-creation-same-branch

Conversation

@rubenmarcus
Copy link
Copy Markdown
Member

Summary

  • Use default branch (main/master) as PR base for the first task, instead of originalBranch which could be an auto/* branch from a previous run
  • Add getDefaultBranch() helper that detects main/master via git symbolic-ref with fallback
  • Strip existing conventional commit prefix from task title to prevent duplicated feat: feat: in PR titles

Root Cause

When auto mode runs on a branch that's already auto/github-1, the first PR would target auto/github-1 as both head and base, causing "No commits between X and X" error.

Test plan

  • Run ralph-starter auto from main branch — first PR should target main
  • Run ralph-starter auto from an auto/* branch — first PR should still target main/master
  • Verify PR titles don't have duplicated prefixes like feat: feat:

Closes #208

🤖 Generated with Claude Code

)

- Use default branch (main/master) as base for first PR instead of
  originalBranch which could be an auto/* branch
- Add getDefaultBranch() helper to detect main/master via git symbolic-ref
- Strip existing conventional commit prefix from task title to prevent
  duplicated "feat: feat:" in PR titles

Closes #208

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added bug Something isn't working candidate-release PR is ready for release core labels Feb 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 23, 2026

✔️ Bundle Size Analysis

Metric Value
Base 1848.54 KB
PR 1850.48 KB
Diff 1.93 KB (0%)
Bundle breakdown
156K	dist/auth
32K	dist/automation
4.0K	dist/cli.d.ts
4.0K	dist/cli.d.ts.map
16K	dist/cli.js
12K	dist/cli.js.map
460K	dist/commands
28K	dist/config
4.0K	dist/index.d.ts
4.0K	dist/index.d.ts.map
4.0K	dist/index.js
4.0K	dist/index.js.map
536K	dist/integrations
84K	dist/llm
728K	dist/loop
172K	dist/mcp
32K	dist/presets
92K	dist/setup
36K	dist/skills
392K	dist/sources
76K	dist/ui
84K	dist/utils
336K	dist/wizard

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Fixes PR creation bug where auto mode would target the same branch as both head and base when running from an existing auto/* branch. Also prevents duplicate conventional commit prefixes in PR titles.

Key changes:

  • Added getDefaultBranch() helper that uses git symbolic-ref to detect main/master with proper fallbacks
  • First PR now targets the repository's default branch instead of originalBranch (which could be an auto/* branch)
  • PR titles strip existing conventional commit prefixes to prevent feat: feat: duplicates
  • The prefix regex is comprehensive, covering all 9 conventional commit types

Note: The prefix-stripping regex on line 164 is more comprehensive (9 types) than the one in buildCommitMessage() on line 272-273 (6 types). Consider unifying these patterns for consistency.

Confidence Score: 4/5

  • This PR is safe to merge with minor inconsistency to address
  • The implementation correctly solves the root cause of the PR creation bug and adds proper fallback logic. The getDefaultBranch() function is well-designed with multiple fallback mechanisms. However, there's a minor style inconsistency between the prefix-stripping regex patterns used in different parts of the code that should be unified for maintainability.
  • No files require special attention - the changes are straightforward and well-contained

Important Files Changed

Filename Overview
src/automation/git.ts Added getDefaultBranch() helper to detect main/master branch via git symbolic-ref with fallback logic
src/loop/task-executor.ts Fixed PR base branch targeting to use default branch and prevented duplicate conventional commit prefixes in PR titles

Last reviewed commit: 3c3d632

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c3d632ae9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rubenmarcus rubenmarcus changed the title fix: PR creation targeting same branch and duplicated feat: prefix fix: prevent PR targeting same branch and duplicated prefix Feb 23, 2026
Address reviewer feedback:
- Greptile: sync buildCommitMessage() prefix regex with cleanTitle regex (add style/ci/perf/build)
- Codex: clarify getDefaultBranch() final fallback comment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04e39e6225

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rubenmarcus rubenmarcus merged commit 4a1bef6 into main Feb 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working candidate-release PR is ready for release claude-code-assisted core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: PR creation fails when head and base branch are the same

1 participant