From 182df5aa9f56baed2dcf2c7a519e2e28df479d75 Mon Sep 17 00:00:00 2001 From: Essien Ita Essien Date: Thu, 4 Jan 2024 14:55:15 +0000 Subject: [PATCH] Issue warning if remaining branch with a remote tracking branch. --- CHANGELOG.md | 3 +++ cli/src/commands/branch.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9006ddb879..bbcc7012f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * New `jj op abandon` command is added to clean up the operation history. If GC is implemented, Git refs and commit objects can be compacted. +* `jj branch rename` will now warn if the renamed branch has a remote branch, since + those will have to be manually renamed outside of `jj`. + ### Fixed bugs diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index d8a975f1ce..7939b98291 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -350,6 +350,21 @@ fn cmd_branch_rename( return Err(user_error(format!("Branch already exists: {new_branch}"))); } + if view + .remote_branches_matching( + &StringPattern::exact(old_branch), + &StringPattern::everything(), + ) + .find(|(_, remote_ref)| remote_ref.is_tracking()) + .is_some() + { + writeln!( + ui.warning(), + "warning: Branch: {}, has remote branches which will not be renamed", + old_branch + )?; + } + let mut tx = workspace_command.start_transaction(); tx.mut_repo() .set_local_branch_target(new_branch, ref_target); @@ -363,6 +378,7 @@ fn cmd_branch_rename( make_branch_term(&[new_branch]), ), )?; + Ok(()) }