ok/jj
1
0
Fork 0
forked from mirrors/jj

branch: ignore git tracking branches for rename warning

Prevents a warning from being printed when renaming branches in a
colocated repo, since git tracking branches were being considered as
remote tracking branches.
This commit is contained in:
Scott Taylor 2024-07-17 19:52:49 -05:00 committed by Scott Taylor
parent 94f5a20cb7
commit d5c526f496
3 changed files with 19 additions and 0 deletions

View file

@ -72,6 +72,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* Windows binaries no longer require `vcruntime140.dll` to be installed
(normally through Visual Studio.)
* `jj branch rename` no longer shows a warning in colocated repos.
## [0.19.0] - 2024-07-03
### Breaking changes

View file

@ -24,6 +24,7 @@ mod untrack;
use itertools::Itertools as _;
use jj_lib::backend::CommitId;
use jj_lib::git;
use jj_lib::op_store::{RefTarget, RemoteRef};
use jj_lib::repo::Repo;
use jj_lib::str_util::StringPattern;
@ -163,6 +164,7 @@ fn find_remote_branches<'a>(
/// local branch.)
fn has_tracked_remote_branches(view: &View, branch: &str) -> bool {
view.remote_branches_matching(&StringPattern::exact(branch), &StringPattern::everything())
.filter(|&((_, remote_name), _)| remote_name != git::REMOTE_NAME_FOR_LOCAL_GIT_REPO)
.any(|(_, remote_ref)| remote_ref.is_tracking())
}

View file

@ -448,6 +448,21 @@ fn test_branch_rename() {
"###);
}
#[test]
fn test_branch_rename_colocated() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo", "--colocate"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=commit-0"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "blocal"]);
// Make sure that git tracking branches don't cause a warning
let (_stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["branch", "rename", "blocal", "blocal1"]);
insta::assert_snapshot!(stderr, @"");
}
#[test]
fn test_branch_forget_glob() {
let test_env = TestEnvironment::default();