-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: warn user if they try to jj bookmark set bookmark@remote
#5423
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG.
Another option is to parse bookmark name as revset symbol, so the user will need to quote bookmark name as `'"foo@bar"' if they really want to create a local bookmark of that name.
That would also catch cases like |
df4e93a
to
88ed179
Compare
i've added revset parsing |
fn parse(name: &str, helper: &WorkspaceCommandHelper) -> Result<Self, CommandError> { | ||
let node = helper.parse_revset_expression(name)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, we can add public revset::parse_symbol() -> Result<String, ..>
function that does parse_program()
and expect_literal()
(or reexport these functions.) Revset aliases shouldn't be expanded, and the other context parameters are unneeded.
Maybe we can add error hint by inspecting the source string? It might be easier if parsed tree (= result of parse_program()
) is available, but I'm not sure.
cli/src/commands/bookmark/mod.rs
Outdated
writeln!( | ||
hint, | ||
"To track remote bookmarks, use: jj bookmark --track {}", | ||
remote_like.join(" ") | ||
)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unparsable name can be just an error, not a warning. I think that's the idea of using revset parser. User can use escape syntax to specify weird bookmark name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unparsable name can be just an error, not a warning. I think that's the idea of using revset parser. User can use escape syntax to specify weird bookmark name.
Sorry, I didn't get it. The only reason to use a revset parser is not to reinvent my own :)
You want to return an error for cases when name was sucessfully parsed as revset(except legit cases) and when it was not parsed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think Yuya just meant the since we're using the real revset parser, we can make it an error. If we had some naive check instead, we might have wanted to make it a warning so we don't prevent valid names. But I'm not 100% sure that's what he meant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
without shell escaping:
foo@bar
-> error"foo@bar"
-> local bookmarkfoo@bar
foo-
-> error"foo-"
-> local bookmarkfoo-
(foo)
-> could be an error (but might be okay to parse as local bookmarkfoo
)
CHANGELOG.md
Outdated
@@ -115,6 +115,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | |||
|
|||
* New `subject(pattern)` revset function that matches first line of commit | |||
descriptions. | |||
* Warn user if he tries to use `jj boookmark set branch@remote` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "he tries" -> "they try"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cli/src/commands/bookmark/mod.rs
Outdated
} | ||
drop(writer); | ||
|
||
let mut hint = ui.hint_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we usually inline these where they're used, so just call ui.hint_default()
on line 235 etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
88ed179
to
aa06bfd
Compare
I'm not sure, maybe there is a legit use case for having
@
in branch name, but most likely it's a mistake.It's also not very consistent with other commands.
You can
jj rebase -d br@origin
, but you can'tjj bookmark set br@origin
after rebasing(I was lazy importing bookmark).Checklist
If applicable:
CHANGELOG.md