Skip to content

fix(git): preserve origin segments in autocommit branches - #42120

Open
wuyua9 wants to merge 1 commit into
appsmithorg:releasefrom
wuyua9:fix/autocommit-strip-only-leading-origin-prefix-clean
Open

fix(git): preserve origin segments in autocommit branches#42120
wuyua9 wants to merge 1 commit into
appsmithorg:releasefrom
wuyua9:fix/autocommit-strip-only-leading-origin-prefix-clean

Conversation

@wuyua9

@wuyua9 wuyua9 commented Aug 13, 2026

Copy link
Copy Markdown

Summary

  • Preserve branch names such as feature/origin/main when autocommit resolves the branched application.
  • Normalize only a leading origin/ prefix, matching the existing Central/Common Git branch contract.
  • Add a regression test covering an internal origin/ segment.

Context

This is the autocommit follow-up to commit 2fe167c7f901 and closed PR #41793. That change corrected the Central/Common branch-listing paths, but GitAutoCommitHelperImpl still used replaceFirst("origin/", ""), which changes feature/origin/main into feature/main. This PR scopes the fix to that missed production site and its focused unit test.

Validation

  • git diff --check passed.
  • Source assertions confirm the old broad replacement is gone and the regression test asserts the exact branch lookup.
  • Focused Maven test was attempted with mvn -pl appsmith-server -Dtest=GitAutoCommitHelperImplTest -DskipITs test, but this environment has no mvn; the repository build also requires Java 17 or 25 while only Java 8/10 are installed here.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Git branch handling so names containing origin as part of the branch path are preserved correctly.
    • Client auto-commit now succeeds reliably for these branch names while maintaining accurate branch protection checks.
  • Tests

    • Added coverage to verify branch lookup, synchronization, and auto-commit behavior for branches containing an origin segment.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: adcf278f-3d64-4910-b4d7-418def0270d2

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd9021 and fea10a7.

📒 Files selected for processing (2)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImpl.java
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImplTest.java

Walkthrough

Branch normalization now removes origin/ only when it is a leading prefix. A regression test verifies that auto-commit preserves feature/origin/main during branch lookup and protection checks.

Changes

Branch name normalization

Layer / File(s) Summary
Normalize and validate branch names
app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImpl.java, app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImplTest.java
The helper strips only a leading origin/ prefix. The test verifies that feature/origin/main remains unchanged during auto-commit.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Mergeability Score: ⚪ Minimal · up to fea10

The change preserves branch names containing internal origin/ segments while removing only a leading remote prefix, with focused regression coverage. No actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested labels: ok-to-test

Suggested reviewers: wyattwalter

Poem

A branch keeps its middle name,
origin/ stays in the chain.
Only leading prefixes flee,
Tests guard the path carefully.
Auto-commit sails free.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: preserving internal origin segments in autocommit branch names.
Description check ✅ Passed The description provides clear scope, motivation, regression-test details, and validation results, but omits several template sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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