Skip to content

Commit

Permalink
Issue warning if remaining branch with a remote tracking branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
essiene committed Jan 5, 2024
1 parent 837ac15 commit 017a753
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
15 changes: 15 additions & 0 deletions cli/src/commands/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,20 @@ 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(),
)
.any(|(_, remote_ref)| remote_ref.is_tracking())
{
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);
Expand All @@ -363,6 +377,7 @@ fn cmd_branch_rename(
make_branch_term(&[new_branch]),
),
)?;

Ok(())
}

Expand Down

0 comments on commit 017a753

Please sign in to comment.