fix(feedback): clone existing batch branch directly to prevent non-fast-forward push failure#2791
Conversation
…h failure Co-authored-by: CommanderStorm <26258709+CommanderStorm@users.noreply.github.com>
CommanderStorm
left a comment
There was a problem hiding this comment.
@copilot instead of the branch_is_new flag on clone_and_checkout, please just add another method to tmp_repo.rs, since the methods content entirely depends on this.
Co-authored-by: CommanderStorm <26258709+CommanderStorm@users.noreply.github.com>
Done in 4725916. |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
Fixes feedback batching pushes by ensuring edits to an existing batch PR fast-forward cleanly, avoiding non-fast-forward rejections when the remote batch branch already exists.
Changes:
- Split
TempRepo::clone_and_checkoutintoclone_and_checkout_new_branchandclone_and_checkout_existing_branch. - Update feedback edit flow to choose the appropriate clone strategy depending on whether a batch PR already exists.
- Adjust existing tests to use the renamed “new branch” clone method.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| server/src/routes/feedback/proposed_edits/tmp_repo.rs | Adds separate clone/checkout paths for new vs. existing remote branches to avoid divergent histories. |
| server/src/routes/feedback/proposed_edits/mod.rs | Threads a branch_is_new flag into edit application to select the correct TempRepo clone method. |
| } | ||
| } | ||
|
|
||
| /// Clone the repository by checking out an already-existing remote branch `branch_name`. | ||
| /// | ||
| /// Use this when adding an edit to an existing batch PR. Cloning `main` and branching from | ||
| /// it would create a diverging history and cause the subsequent push to be rejected as | ||
| /// non-fast-forward. | ||
| #[tracing::instrument] | ||
| pub async fn clone_and_checkout_existing_branch( |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
When a batch PR already exists, subsequent coordinate feedback submissions failed with "Could apply changes, please try again later" because the git push was rejected.
Proposed Change(s)
clone_and_checkoutintmp_repo.rsalways clonedmainthen rangit checkout -b <branch> main, creating a local branch that diverged from the existing remote batch branch. The push was rejected as non-fast-forward.clone_and_checkoutinto two dedicated methods intmp_repo.rs:clone_and_checkout_new_branch— clonesmainand creates a fresh branch from it (used when no batch PR exists yet)clone_and_checkout_existing_branch— clones directly with--branch <name>to check out the already-existing remote branch (used when adding an edit to an existing batch PR), making the subsequent push a clean fast-forwardChecklist
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.