mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 00:50:57 +00:00
cli: bookmark list: extend --remote filter to string patterns
I don't have a practical use case, but I think this is more consistent with NAMES arguments.
This commit is contained in:
parent
63785a24da
commit
fc3e99d0e9
3 changed files with 24 additions and 9 deletions
|
@ -44,10 +44,21 @@ pub struct BookmarkListArgs {
|
|||
all_remotes: bool,
|
||||
|
||||
/// Show all tracking and non-tracking remote bookmarks belonging
|
||||
/// to this remote. Can be combined with `--tracked` or
|
||||
/// `--conflicted` to filter the bookmarks shown (can be repeated)
|
||||
#[arg(long = "remote", value_name = "REMOTE", conflicts_with_all = ["all_remotes"])]
|
||||
remotes: Option<Vec<String>>,
|
||||
/// to this remote
|
||||
///
|
||||
/// Can be combined with `--tracked` or `--conflicted` to filter the
|
||||
/// bookmarks shown (can be repeated.)
|
||||
///
|
||||
/// By default, the specified remote name matches exactly. Use `glob:`
|
||||
/// prefix to select remotes by wildcard pattern. For details, see
|
||||
/// https://martinvonz.github.io/jj/latest/revsets/#string-patterns.
|
||||
#[arg(
|
||||
long = "remote",
|
||||
value_name = "REMOTE",
|
||||
conflicts_with_all = ["all_remotes"],
|
||||
value_parser = StringPattern::parse,
|
||||
)]
|
||||
remotes: Option<Vec<StringPattern>>,
|
||||
|
||||
/// Show remote tracked bookmarks only. Omits local Git-tracking bookmarks
|
||||
/// by default
|
||||
|
@ -151,9 +162,9 @@ pub fn cmd_bookmark_list(
|
|||
.iter()
|
||||
.copied()
|
||||
.filter(|&(remote_name, _)| {
|
||||
args.remotes
|
||||
.as_ref()
|
||||
.map_or(true, |names| names.iter().any(|r| r == remote_name))
|
||||
args.remotes.as_ref().map_or(true, |patterns| {
|
||||
patterns.iter().any(|pattern| pattern.matches(remote_name))
|
||||
})
|
||||
})
|
||||
.partition::<Vec<_>, _>(|&(_, remote_ref)| remote_ref.is_tracking());
|
||||
|
||||
|
|
|
@ -318,7 +318,11 @@ For information about bookmarks, see https://martinvonz.github.io/jj/latest/book
|
|||
###### **Options:**
|
||||
|
||||
* `-a`, `--all-remotes` — Show all tracking and non-tracking remote bookmarks including the ones whose targets are synchronized with the local bookmarks
|
||||
* `--remote <REMOTE>` — Show all tracking and non-tracking remote bookmarks belonging to this remote. Can be combined with `--tracked` or `--conflicted` to filter the bookmarks shown (can be repeated)
|
||||
* `--remote <REMOTE>` — Show all tracking and non-tracking remote bookmarks belonging to this remote
|
||||
|
||||
Can be combined with `--tracked` or `--conflicted` to filter the bookmarks shown (can be repeated.)
|
||||
|
||||
By default, the specified remote name matches exactly. Use `glob:` prefix to select remotes by wildcard pattern. For details, see https://martinvonz.github.io/jj/latest/revsets/#string-patterns.
|
||||
* `-t`, `--tracked` — Show remote tracked bookmarks only. Omits local Git-tracking bookmarks by default
|
||||
* `-c`, `--conflicted` — Show conflicted bookmarks only
|
||||
* `-r`, `--revisions <REVISIONS>` — Show bookmarks whose local targets are in the given revisions
|
||||
|
|
|
@ -1547,7 +1547,7 @@ fn test_bookmark_list_filtered() {
|
|||
insta::assert_snapshot!(stderr, @r#"
|
||||
Hint: Bookmarks marked as deleted will be *deleted permanently* on the remote on the next `jj git push`. Use `jj bookmark forget` to prevent this.
|
||||
"#);
|
||||
let (stdout, stderr) = query(&["--remote", "git"]);
|
||||
let (stdout, stderr) = query(&["--remote", "glob:gi?"]);
|
||||
insta::assert_snapshot!(stdout, @r#"
|
||||
local-keep: kpqxywon c7b4c09c (empty) local-keep
|
||||
@git: kpqxywon c7b4c09c (empty) local-keep
|
||||
|
|
Loading…
Reference in a new issue