Allow configuring fork push remote from CLI#14708
Conversation
167ec7c to
7d2bef2
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for configuring a separate push remote when setting the project target branch via but config target, enabling fork workflows (review against upstream/* while pushing to origin).
Changes:
- Extends
but config targetCLI args with--push-remoteand enforces that it can only be used when a target branch is provided. - Wires the new flag through the config command execution path to update project metadata (target ref + optional push remote).
- Adds CLI parsing tests and an integration test asserting
gitbutler.project.targetRefandgitbutler.project.pushRemoteare set as expected.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/but/tests/but/command/config.rs | Adds an integration test verifying target and push-remote are stored distinctly for fork workflows. |
| crates/but/src/command/config.rs | Threads --push-remote through config target handling and validates the named remote before updating metadata. |
| crates/but/src/args/tests.rs | Adds argument-shape tests for config target --push-remote parsing and validation. |
| crates/but/src/args/config.rs | Adds the --push-remote flag and CLI docs for fork push-remote configuration. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d2bef2b45
ℹ️ 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".
| but_api::workspace::set_target_ref_and_init_project( | ||
| ctx, | ||
| new_branch.clone(), | ||
| None, | ||
| target_ref.as_ref(), | ||
| push_remote, | ||
| )?; |
There was a problem hiding this comment.
Recompute the base when changing the target
When a repo already has gitbutler.project.targetCommitId and the user changes to a target whose merge-base differs, this now calls set_target_ref_and_init_project(), which preserves the existing target commit id instead of recomputing it. That leaves targetRef pointing at the new branch while base_sha/targetCommitId still comes from the old target, so target/status/integration calculations using ProjectMeta::target_commit_id operate against the wrong base; the previous set_base_branch path recomputed the merge-base for the requested branch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Seems to be encoded in a test. This should be fixed in another PR
7d2bef2 to
27b78fe
Compare
27b78fe to
7de9765
Compare
| let target_ref: gix::refs::FullName = format!("refs/remotes/{new_branch}") | ||
| .try_into() | ||
| .context("Invalid target branch name")?; |
7de9765 to
cd074f4
Compare
🧢 Changes
Adds
--push-remotetobut config target, validates the named remote, and routes target updates through the new workspace API.Adds CLI parsing coverage and an API test for distinct upstream target and fork push remotes.
☕️ Reasoning
Fork contributors need to configure
upstream/mainas the review target while pushing branches tooriginwithout first opening the desktop app.Validated with focused tests, formatting,
cargo check, and Clippy forbutandbut-api.