mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-19 10:44:58 +00:00
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:
parent
94f5a20cb7
commit
d5c526f496
3 changed files with 19 additions and 0 deletions
|
@ -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
|
* Windows binaries no longer require `vcruntime140.dll` to be installed
|
||||||
(normally through Visual Studio.)
|
(normally through Visual Studio.)
|
||||||
|
|
||||||
|
* `jj branch rename` no longer shows a warning in colocated repos.
|
||||||
|
|
||||||
## [0.19.0] - 2024-07-03
|
## [0.19.0] - 2024-07-03
|
||||||
|
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
|
|
|
@ -24,6 +24,7 @@ mod untrack;
|
||||||
|
|
||||||
use itertools::Itertools as _;
|
use itertools::Itertools as _;
|
||||||
use jj_lib::backend::CommitId;
|
use jj_lib::backend::CommitId;
|
||||||
|
use jj_lib::git;
|
||||||
use jj_lib::op_store::{RefTarget, RemoteRef};
|
use jj_lib::op_store::{RefTarget, RemoteRef};
|
||||||
use jj_lib::repo::Repo;
|
use jj_lib::repo::Repo;
|
||||||
use jj_lib::str_util::StringPattern;
|
use jj_lib::str_util::StringPattern;
|
||||||
|
@ -163,6 +164,7 @@ fn find_remote_branches<'a>(
|
||||||
/// local branch.)
|
/// local branch.)
|
||||||
fn has_tracked_remote_branches(view: &View, branch: &str) -> bool {
|
fn has_tracked_remote_branches(view: &View, branch: &str) -> bool {
|
||||||
view.remote_branches_matching(&StringPattern::exact(branch), &StringPattern::everything())
|
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())
|
.any(|(_, remote_ref)| remote_ref.is_tracking())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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]
|
#[test]
|
||||||
fn test_branch_forget_glob() {
|
fn test_branch_forget_glob() {
|
||||||
let test_env = TestEnvironment::default();
|
let test_env = TestEnvironment::default();
|
||||||
|
|
Loading…
Reference in a new issue