Skip to content

[WAR-7378] Fix: Use fork point for PR diffs and commit message retrieval and remove parent branch logic#9238

Merged
exzshao merged 14 commits intomasterfrom
edward/war-7378-use-forkpoint-commit
Apr 29, 2026
Merged

[WAR-7378] Fix: Use fork point for PR diffs and commit message retrieval and remove parent branch logic#9238
exzshao merged 14 commits intomasterfrom
edward/war-7378-use-forkpoint-commit

Conversation

@exzshao
Copy link
Copy Markdown
Contributor

@exzshao exzshao commented Apr 28, 2026

Description

This change updates the Git dialogs to compare against the correct parent branch instead of the previous broken detect_parent_branch

Specifically, this PR:

  • Introduces detect_fork_point to determine the point where the current branch diverged from its parent.
  • Uses the fork point when no parent branch is specified, ensuring accurate diffs even when the parent branch is not explicitly set.

Fixes WAR-7378

Testing

Tested manually by verifying that diffs and commit message generation now correctly use the fork point rather than main when working on stacked branches.

Server API dependencies

N/A

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Co-Authored-By: Oz oz-agent@warp.dev

This change updates the Git dialogs to compare against the correct parent
branch instead of always using the main branch. Specifically:

- Replaces detect_main_branch with detect_parent_branch in several locations
  to determine the base for diffs and commit messages.
- Introduces detect_fork_point to determine the point where the current branch
  diverged from its parent.
- Uses the fork point when no parent branch is specified, ensuring accurate
  diffs even when the parent branch is not explicitly set.

Fixes WAR-7378

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Apr 28, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 28, 2026

@exzshao

I'm starting a first review of this pull request.

You can follow along in the session on Warp.

I completed the review and posted feedback on this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@exzshao exzshao requested a review from MaggieShan April 28, 2026 15:24
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR changes the Git dialog diff, commit-message, and PR-base helpers to use a fork-point SHA for branch-specific changes and updates the related tech spec.

Concerns

  • detect_fork_point only excludes origin/<current> as the branch's remote copy; branches tracking a different remote or differently named upstream can subtract their own upstream and collapse the fork point to HEAD, producing empty PR diffs/AI content.
  • detect_parent_branch_with_context ranks all refs containing the fork point without measuring which branch tip is closest to that fork, so gh pr create --base can target an unrelated branch that merely contains the same ancestor.

Verdict

Found: 0 critical, 2 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/util/git.rs Outdated
Comment thread app/src/util/git.rs Outdated
Comment thread app/src/util/git.rs Outdated

/// See the no-`local_fs` stub above for documentation.
#[cfg(feature = "local_fs")]
pub async fn detect_fork_point(repo_path: &Path) -> Result<Option<String>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a way we can reduce the amount of times this is called? Maybe computed + stored alongside the parent branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's fine, cache seems complicated cuz a lot of things can invalidate the state and then we need to know when to re-compute. Also this is only computed for branches with no upstream.

Comment thread app/src/util/git.rs Outdated
@exzshao exzshao changed the title [WAR-7378] Fix: Use fork point for PR diffs and commit message retrieval [WAR-7378] Fix: Use fork point for PR diffs and commit message retrieval and remove parent branch logic Apr 28, 2026
Co-Authored-By: Oz <oz-agent@warp.dev>
@exzshao exzshao requested a review from MaggieShan April 28, 2026 23:42
Comment thread app/src/code_review/git_dialog/commit.rs Outdated
Comment thread app/src/util/git.rs Outdated
Comment thread app/src/code_review/git_dialog/pr.rs Outdated
Comment thread specs/APP-4218/TECH.md
@exzshao exzshao requested a review from MaggieShan April 29, 2026 18:07
@exzshao exzshao merged commit 1d2775a into master Apr 29, 2026
32 checks passed
@exzshao exzshao deleted the edward/war-7378-use-forkpoint-commit branch April 29, 2026 18:21
zerx-lab pushed a commit to zerx-lab/warp that referenced this pull request May 3, 2026
…val and remove parent branch logic (warpdotdev#9238)

## Description
This change updates the Git dialogs to compare against the correct
parent branch instead of the previous broken detect_parent_branch

Specifically, this PR:
- Introduces `detect_fork_point` to determine the point where the
current branch diverged from its parent.
- Uses the fork point when no parent branch is specified, ensuring
accurate diffs even when the parent branch is not explicitly set.

Fixes
[WAR-7378](https://linear.app/warpdotdev/issue/WAR-7378/fix-publish-and-pr-on-diverged-parent-branch-bug)

## Testing
Tested manually by verifying that diffs and commit message generation
now correctly use the fork point rather than main when working on
stacked branches.

## Server API dependencies
N/A

## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Co-Authored-By: Oz <oz-agent@warp.dev>

---------

Co-authored-by: Oz <oz-agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants