mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 18:27:38 +00:00
revset: exclude @git branches from remote_branches()
As discussed in Discord, it's less useful if remote_branches() included Git-tracking branches. Users wouldn't consider the backing Git repo as a remote. We could allow explicit 'remote_branches(remote=exact:"git")' query by changing the default remote pattern to something like 'remote=~exact:"git"'. I don't know which will be better overall, but we don't have support for negative patterns anyway.
This commit is contained in:
parent
7d9223d734
commit
2ac9865ce7
5 changed files with 19 additions and 5 deletions
|
@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
|
|
||||||
|
* The `remote_branches()` revset no longer includes branches exported to the Git
|
||||||
|
repository (so called Git-tracking branches.)
|
||||||
|
|
||||||
### New features
|
### New features
|
||||||
|
|
||||||
* `jj workspace add` can now take _multiple_ `--revision` arguments, which will
|
* `jj workspace add` can now take _multiple_ `--revision` arguments, which will
|
||||||
|
@ -33,8 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
clone to see the full speedup.
|
clone to see the full speedup.
|
||||||
|
|
||||||
* The `remote_branches()` revset now includes branches exported to the Git
|
* The `remote_branches()` revset now includes branches exported to the Git
|
||||||
repository (so called Git-tracking branches.) Use
|
repository (so called Git-tracking branches.) *This change will be reverted
|
||||||
`remote_branches(remote=exact:"origin")` to query branches of certain remote.
|
in 0.12.0.*
|
||||||
|
|
||||||
* Status messages are now printed to stderr.
|
* Status messages are now printed to stderr.
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,8 @@ fn test_resolution_of_git_tracking_branches() {
|
||||||
insta::assert_snapshot!(query("main@git"), @r###"
|
insta::assert_snapshot!(query("main@git"), @r###"
|
||||||
16d541ca40f42baf2dea41aa61a0b5f1cbf1f91b old_message
|
16d541ca40f42baf2dea41aa61a0b5f1cbf1f91b old_message
|
||||||
"###);
|
"###);
|
||||||
insta::assert_snapshot!(query(r#"remote_branches(exact:"main", exact:"git")"#), @r###"
|
// Can't be selected by remote_branches()
|
||||||
16d541ca40f42baf2dea41aa61a0b5f1cbf1f91b old_message
|
insta::assert_snapshot!(query(r#"remote_branches(exact:"main", exact:"git")"#), @"");
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -112,6 +112,9 @@ revsets (expressions) as arguments.
|
||||||
`main@origin` or `main@upstream`. If a branch is in a conflicted state, all
|
`main@origin` or `main@upstream`. If a branch is in a conflicted state, all
|
||||||
its possible targets are included.
|
its possible targets are included.
|
||||||
|
|
||||||
|
While Git-tracking branches can be selected by `<name>@git`, these branches
|
||||||
|
aren't included in `remote_branches()`.
|
||||||
|
|
||||||
* `tags()`: All tag targets. If a tag is in a conflicted state, all its
|
* `tags()`: All tag targets. If a tag is in a conflicted state, all its
|
||||||
possible targets are included.
|
possible targets are included.
|
||||||
|
|
||||||
|
|
|
@ -2147,9 +2147,11 @@ fn resolve_commit_ref(
|
||||||
branch_pattern,
|
branch_pattern,
|
||||||
remote_pattern,
|
remote_pattern,
|
||||||
} => {
|
} => {
|
||||||
|
// TODO: should we allow to select @git branches explicitly?
|
||||||
let commit_ids = repo
|
let commit_ids = repo
|
||||||
.view()
|
.view()
|
||||||
.remote_branches_matching(branch_pattern, remote_pattern)
|
.remote_branches_matching(branch_pattern, remote_pattern)
|
||||||
|
.filter(|&((_, remote_name), _)| remote_name != git::REMOTE_NAME_FOR_LOCAL_GIT_REPO)
|
||||||
.flat_map(|(_, remote_ref)| remote_ref.target.added_ids())
|
.flat_map(|(_, remote_ref)| remote_ref.target.added_ids())
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -1836,12 +1836,19 @@ fn test_evaluate_expression_remote_branches() {
|
||||||
let commit2 = write_random_commit(mut_repo, &settings);
|
let commit2 = write_random_commit(mut_repo, &settings);
|
||||||
let commit3 = write_random_commit(mut_repo, &settings);
|
let commit3 = write_random_commit(mut_repo, &settings);
|
||||||
let commit4 = write_random_commit(mut_repo, &settings);
|
let commit4 = write_random_commit(mut_repo, &settings);
|
||||||
|
let commit_git_remote = write_random_commit(mut_repo, &settings);
|
||||||
|
|
||||||
// Can get branches when there are none
|
// Can get branches when there are none
|
||||||
assert_eq!(resolve_commit_ids(mut_repo, "remote_branches()"), vec![]);
|
assert_eq!(resolve_commit_ids(mut_repo, "remote_branches()"), vec![]);
|
||||||
// Can get a few branches
|
// Can get a few branches
|
||||||
mut_repo.set_remote_branch("branch1", "origin", normal_remote_ref(commit1.id()));
|
mut_repo.set_remote_branch("branch1", "origin", normal_remote_ref(commit1.id()));
|
||||||
mut_repo.set_remote_branch("branch2", "private", normal_remote_ref(commit2.id()));
|
mut_repo.set_remote_branch("branch2", "private", normal_remote_ref(commit2.id()));
|
||||||
|
// Git-tracking branches aren't included
|
||||||
|
mut_repo.set_remote_branch(
|
||||||
|
"branch",
|
||||||
|
git::REMOTE_NAME_FOR_LOCAL_GIT_REPO,
|
||||||
|
normal_remote_ref(commit_git_remote.id()),
|
||||||
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, "remote_branches()"),
|
resolve_commit_ids(mut_repo, "remote_branches()"),
|
||||||
vec![commit2.id().clone(), commit1.id().clone()]
|
vec![commit2.id().clone(), commit1.id().clone()]
|
||||||
|
|
Loading…
Reference in a new issue