Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

refactor(git): drop Branch::push_remote, unused since the @{push} fix (#3833)

Worktrunk Botaa4e527f3574
diff --git a/src/commands/list/ci_status/github.rs b/src/commands/list/ci_status/github.rs
index 1d47a9083..0f2b1ec2b 100644
--- a/src/commands/list/ci_status/github.rs
+++ b/src/commands/list/ci_status/github.rs
@@ -41,7 +41,7 @@ pub(super) fn detect_github(
let repo_root = repo.current_worktree().root().ok()?;
// Get the owner of the branch's push remote for filtering PRs by source repository.
- // For local branches: uses @{push} which resolves through pushRemote → remote.pushDefault → tracking remote.
+ // For local branches: resolves through pushRemote → remote.pushDefault → tracking remote.
// For remote branches: use the remote's effective URL (handles insteadOf aliases).
let branch_owner = branch_owner_repo(repo, branch).map(|(owner, _)| owner);
diff --git a/src/git/repository/branch.rs b/src/git/repository/branch.rs
index d0b03b2f2..c8a514e0c 100644
--- a/src/git/repository/branch.rs
+++ b/src/git/repository/branch.rs
@@ -138,31 +138,6 @@ impl<'a> Branch<'a> {
Ok(())
}
- /// Get the remote where this branch would be pushed.
- ///
- /// Uses [`@{push}` syntax][1] which resolves through:
- /// 1. `branch.<name>.pushRemote` (branch-specific push remote)
- /// 2. `remote.pushDefault` (default push remote for all branches)
- /// 3. `branch.<name>.remote` (tracking remote)
- ///
- /// Returns `None` if no push destination is configured.
- ///
- /// [1]: https://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltbraboranchgtpaboranchgtpush
- pub fn push_remote(&self) -> Option<String> {
- let push_ref = self
- .repo
- .run_command(&[
- "rev-parse",
- "--abbrev-ref",
- &format!("{}@{{push}}", self.name),
- ])
- .ok()?;
-
- // Returns "origin/branch", extract remote name
- let remote = push_ref.trim().split('/').next()?;
- (!remote.is_empty()).then(|| remote.to_string())
- }
-
/// Get the URL of the remote where this branch would be pushed.
///
/// Uses `%(push:remotename)` which returns either a remote name or URL directly
diff --git a/tests/integration_tests/ci_status.rs b/tests/integration_tests/ci_status.rs
index 7c2900e40..5e010e105 100644
--- a/tests/integration_tests/ci_status.rs
+++ b/tests/integration_tests/ci_status.rs
@@ -19,10 +19,12 @@ fn branch_sha(repo: &TestRepo, branch: &str) -> String {
repo.git_output(&["rev-parse", branch])
}
-/// Set up tracking for all branches so @{push} resolves correctly.
+/// Set up tracking for all branches so `push_remote_url()` resolves a push
+/// destination.
///
-/// @{push} requires both tracking config AND the remote-tracking ref to exist.
-/// This is normally done by fetch/push, but in tests we create refs manually.
+/// `%(push:remotename)` reads the `branch.<name>.{remote,merge}` config. The
+/// remote-tracking ref that fetch/push would normally create is set up
+/// alongside it, so the fixture matches a real clone.
fn setup_tracking_for_all_branches(repo: &TestRepo, remote: &str) {
for branch in ["feature", "feature-a", "feature-b", "feature-c", "main"] {
repo.run_git(&["config", &format!("branch.{}.remote", branch), remote]);
@@ -739,7 +741,8 @@ fn test_list_full_with_gitlab_multiple_mrs_no_project_id(mut repo: TestRepo) {
/// - branch.<name>.pushremote = https://github.com/fork-owner/repo.git (a URL)
/// - branch.<name>.merge = refs/pull/123/head (a PR ref)
///
-/// Git's @{push} syntax fails with URLs, so we fall back to reading the config directly.
+/// Git's @{push} syntax fails when the push remote is a URL, so
+/// `push_remote_url()` reads `%(push:remotename)`, which returns the URL directly.
#[rstest]
fn test_list_full_with_url_based_pushremote(mut repo: TestRepo) {
// Set origin URL (the upstream repo where PRs are opened)
diff --git a/tests/integration_tests/default_branch.rs b/tests/integration_tests/default_branch.rs
index 95d8a7983..97d24c4c1 100644
--- a/tests/integration_tests/default_branch.rs
+++ b/tests/integration_tests/default_branch.rs
@@ -436,7 +436,7 @@ fn setup_insteadof(repo: &TestRepo, remote: &str, custom_url: &str, real_prefix:
]);
}
-/// Set up push tracking so `branch.push_remote()` and `github_push_url()` work.
+/// Set up push tracking so `branch.push_remote_url()` resolves a push destination.
fn setup_push_tracking(repo: &TestRepo, branch: &str, remote: &str) {
repo.run_git(&["config", &format!("branch.{branch}.remote"), remote]);
repo.run_git(&[