cli: update hints to use new "track/untrack --remote" syntax

This commit is contained in:
Yuya Nishihara 2025-12-06 13:51:07 +09:00
parent e921791574
commit f4dc07eb3c
7 changed files with 41 additions and 30 deletions

View file

@ -811,7 +811,10 @@ fn bookmark_name_parse_error_hint(err: &BookmarkNameParseError) -> Option<String
use revset::ExpressionKind;
match revset::parse_program(&err.input).map(|node| node.kind) {
Ok(ExpressionKind::RemoteSymbol(symbol)) => Some(format!(
"Looks like remote bookmark. Run `jj bookmark track {symbol}` to track it."
"Looks like remote bookmark. Run `jj bookmark track {name} --remote={remote}` to \
track it.",
name = symbol.name.as_symbol(),
remote = symbol.remote.as_symbol()
)),
_ => Some(REVSET_SYMBOL_HINT.to_owned()),
}

View file

@ -119,8 +119,10 @@ pub fn cmd_bookmark_rename(
)?;
writeln!(
ui.hint_default(),
"To track the existing remote bookmark, run `jj bookmark track \
{new_remote_bookmark}`",
"To track the existing remote bookmark, run `jj bookmark track {name} \
--remote={remote}`",
name = new_remote_bookmark.name.as_symbol(),
remote = new_remote_bookmark.remote.as_symbol()
)?;
continue;
}
@ -162,9 +164,8 @@ pub fn cmd_bookmark_rename(
)?;
writeln!(
ui.hint_default(),
"Run `jj bookmark untrack 'glob:{new_bookmark}@*'` to disassociate them.",
// TODO: use .as_symbol() if pattern parser is ported to revset
new_bookmark = new_bookmark.as_str()
"Run `jj bookmark untrack {new_bookmark}` to disassociate them.",
new_bookmark = new_bookmark.as_symbol()
)?;
}

View file

@ -18,7 +18,6 @@ use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
use indoc::writedoc;
use itertools::Itertools as _;
use jj_lib::file_util;
use jj_lib::git;
@ -322,14 +321,18 @@ fn print_trackable_remote_bookmarks(ui: &Ui, view: &View) -> io::Result<()> {
write!(formatter, " ")?;
writeln!(formatter.labeled("bookmark"), "{symbol}")?;
}
writedoc!(
writeln!(
formatter.labeled("hint").with_heading("Hint: "),
"
Run the following command to keep local bookmarks updated on future pulls:
jj bookmark track {syms}
",
syms = remote_bookmark_symbols.iter().join(" ")
"Run the following command to keep local bookmarks updated on future pulls:"
)?;
for symbol in &remote_bookmark_symbols {
writeln!(
formatter.labeled("hint"),
" jj bookmark track {name} --remote={remote}",
name = symbol.name.as_symbol(),
remote = symbol.remote.as_symbol()
)?;
}
}
Ok(())
}

View file

@ -792,7 +792,9 @@ fn classify_bookmark_update(
BookmarkPushAction::RemoteUntracked => Err(RejectedBookmarkUpdateReason {
message: format!("Non-tracking remote bookmark {remote_symbol} exists"),
hint: Some(format!(
"Run `jj bookmark track {remote_symbol}` to import the remote bookmark."
"Run `jj bookmark track {name} --remote={remote}` to import the remote bookmark.",
name = remote_symbol.name.as_symbol(),
remote = remote_symbol.remote.as_symbol()
)),
}),
// TODO: deprecate --allow-new and make classify_bookmark_push_action()
@ -801,7 +803,9 @@ fn classify_bookmark_update(
Err(RejectedBookmarkUpdateReason {
message: format!("Refusing to create new remote bookmark {remote_symbol}"),
hint: Some(format!(
"Run `jj bookmark track {remote_symbol}` and try again."
"Run `jj bookmark track {name} --remote={remote}` and try again.",
name = remote_symbol.name.as_symbol(),
remote = remote_symbol.remote.as_symbol()
)),
})
}
@ -835,7 +839,7 @@ fn ensure_new_bookmark_name(repo: &dyn Repo, name: &RefName) -> Result<(), Comma
format!("Tracked remote bookmarks exist for deleted bookmark: {symbol}"),
format!(
"Use `jj bookmark set` to recreate the local bookmark. Run `jj bookmark untrack \
'glob:{symbol}@*'` to disassociate them."
{symbol}` to disassociate them."
),
));
}

View file

@ -227,7 +227,7 @@ fn test_bookmark_bad_name() {
| ^---
|
= expected <EOI>
Hint: Looks like remote bookmark. Run `jj bookmark track foo@bar` to track it.
Hint: Looks like remote bookmark. Run `jj bookmark track foo --remote=bar` to track it.
[EOF]
[exit status: 2]
");
@ -659,7 +659,7 @@ fn test_bookmark_rename() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Warning: Tracked remote bookmarks for bookmark bremote exist.
Hint: Run `jj bookmark untrack 'glob:bremote@*'` to disassociate them.
Hint: Run `jj bookmark untrack bremote` to disassociate them.
[EOF]
");
work_dir
@ -682,7 +682,7 @@ fn test_bookmark_rename() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Warning: The renamed bookmark already exists on the remote 'origin', tracking state was dropped.
Hint: To track the existing remote bookmark, run `jj bookmark track bremote-untracked@origin`
Hint: To track the existing remote bookmark, run `jj bookmark track bremote-untracked --remote=origin`
Warning: Tracked remote bookmarks for bookmark bremote2 were not renamed.
Hint: To rename the bookmark on the remote, you can `jj git push --bookmark bremote2` first (to delete it on the remote), and then `jj git push --bookmark bremote-untracked`. `jj git push --all --deleted` would also be sufficient.
[EOF]

View file

@ -728,7 +728,7 @@ fn test_git_init_colocated_via_git_repo_path_imported_refs() {
Hint: The following remote bookmarks aren't associated with the existing local bookmarks:
local-remote@origin
Hint: Run the following command to keep local bookmarks updated on future pulls:
jj bookmark track local-remote@origin
jj bookmark track local-remote --remote=origin
Initialized repo in "."
[EOF]
"#);

View file

@ -592,7 +592,7 @@ fn test_git_push_locally_created_and_rewritten() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Warning: Refusing to create new remote bookmark my@origin
Hint: Run `jj bookmark track my@origin` and try again.
Hint: Run `jj bookmark track my --remote=origin` and try again.
Nothing changed.
[EOF]
");
@ -1087,7 +1087,7 @@ fn test_git_push_changes_with_name_deleted_tracked() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Error: Tracked remote bookmarks exist for deleted bookmark: b1
Hint: Use `jj bookmark set` to recreate the local bookmark. Run `jj bookmark untrack 'glob:b1@*'` to disassociate them.
Hint: Use `jj bookmark set` to recreate the local bookmark. Run `jj bookmark untrack b1` to disassociate them.
[EOF]
[exit status: 1]
");
@ -1095,7 +1095,7 @@ fn test_git_push_changes_with_name_deleted_tracked() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Error: Tracked remote bookmarks exist for deleted bookmark: b1
Hint: Use `jj bookmark set` to recreate the local bookmark. Run `jj bookmark untrack 'glob:b1@*'` to disassociate them.
Hint: Use `jj bookmark set` to recreate the local bookmark. Run `jj bookmark untrack b1` to disassociate them.
[EOF]
[exit status: 1]
");
@ -1179,7 +1179,7 @@ fn test_git_push_changes_with_name_untracked_or_forgotten() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Error: Non-tracking remote bookmark b1@origin exists
Hint: Run `jj bookmark track b1@origin` to import the remote bookmark.
Hint: Run `jj bookmark track b1 --remote=origin` to import the remote bookmark.
[EOF]
[exit status: 1]
");
@ -1188,7 +1188,7 @@ fn test_git_push_changes_with_name_untracked_or_forgotten() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Error: Non-tracking remote bookmark b1@origin exists
Hint: Run `jj bookmark track b1@origin` to import the remote bookmark.
Hint: Run `jj bookmark track b1 --remote=origin` to import the remote bookmark.
[EOF]
[exit status: 1]
");
@ -1364,7 +1364,7 @@ fn test_git_push_mixed() {
------- stderr -------
Creating bookmark push-yqosqzytrlsw for revision yqosqzytrlsw
Error: Refusing to create new remote bookmark bookmark-1@origin
Hint: Run `jj bookmark track bookmark-1@origin` and try again.
Hint: Run `jj bookmark track bookmark-1 --remote=origin` and try again.
[EOF]
[exit status: 1]
");
@ -1906,7 +1906,7 @@ fn test_git_push_tracked_vs_all() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Warning: Non-tracking remote bookmark bookmark1@origin exists
Hint: Run `jj bookmark track bookmark1@origin` to import the remote bookmark.
Hint: Run `jj bookmark track bookmark1 --remote=origin` to import the remote bookmark.
Changes to push to origin:
Add bookmark bookmark3 to 0004a65e1d28
[EOF]
@ -1932,7 +1932,7 @@ fn test_git_push_moved_forward_untracked() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Warning: Non-tracking remote bookmark bookmark1@origin exists
Hint: Run `jj bookmark track bookmark1@origin` to import the remote bookmark.
Hint: Run `jj bookmark track bookmark1 --remote=origin` to import the remote bookmark.
Nothing changed.
[EOF]
");
@ -1957,7 +1957,7 @@ fn test_git_push_moved_sideways_untracked() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Warning: Non-tracking remote bookmark bookmark1@origin exists
Hint: Run `jj bookmark track bookmark1@origin` to import the remote bookmark.
Hint: Run `jj bookmark track bookmark1 --remote=origin` to import the remote bookmark.
Nothing changed.
[EOF]
");
@ -2136,7 +2136,7 @@ fn test_git_push_sign_on_push() {
insta::assert_snapshot!(output, @r"
------- stderr -------
Warning: Refusing to create new remote bookmark bookmark3@origin
Hint: Run `jj bookmark track bookmark3@origin` and try again.
Hint: Run `jj bookmark track bookmark3 --remote=origin` and try again.
Changes to push to origin:
Move forward bookmark bookmark2 from d45e2adce0ad to 48ea83e9499c
[EOF]