Skip to content
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: add test to ensure the default config has no symbol aliases #4437

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thoughtpolice
Copy link
Collaborator

@thoughtpolice thoughtpolice commented Sep 11, 2024

In #4432 I submitted a patch to ship a symbol alias in the default configuration. However, Yuya quickly pointed out that this isn't acceptable because symbols override all branch and tag names, meaning that the name at would have at best been taken away from users, and at worst been very confusing for them down the road had they ever tried to use it.

I should have thought of this myself (I encountered it long ago when first using Jujutsu, actually) but didn't. Such is life.

But this didn't cause any tests to fail, as it was not immediately clear this would impede anything or cause downstream behavioral changes; the problems it adds are actually latent and it's very possible someone will want to make the same mistake in the future. And Yuya might not be able to stop them (me) in time; requiring him to go out of his way and then handle the fallout. I'm not a fan of this.

Instead, let's patch this latent hole for good, or until we decide otherwise, by applying the Beyonce Rule: "if you liked that behavior, then you shoulda put a test on it."

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@thoughtpolice
Copy link
Collaborator Author

@yuja The "is this a symbol" check is a complete hack, but maybe that's OK. Let me know what you think.

In #4432 I submitted a patch to ship a symbol alias in the default
configuration. However, Yuya quickly pointed out that this isn't acceptable
because symbols override all branch and tag names, meaning that the name `at`
would have at best been taken  away from users, and at worst been very confusing
for them down the road had they ever tried to use it.

I should have thought of this myself (I encountered it long ago when first using
Jujutsu, actually) but didn't. Such is life.

But this didn't cause any tests to fail, as it was not immediately clear this
would impede anything or cause downstream behavioral changes; the problems it
adds are actually latent and it's very possible someone will want to make the
same mistake in the future. And Yuya might not be able to stop them (me) in
time; requiring him to go out of his way and then handle the fallout. I'm not a
fan of this.

Instead, let's patch this latent hole for good, or until we decide otherwise, by
applying the Beyonce Rule: "if you liked that behavior, then you shoulda put a
test on it."

Signed-off-by: Austin Seipp <[email protected]>
// and so testing for the presence of a closing parenthesis is
// sufficient to ensure we're not introducing a symbol.
if !alias.ends_with(")") {
anyhow::bail!(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just be return

@yuja
Copy link
Collaborator

yuja commented Sep 11, 2024

@yuja The "is this a symbol" check is a complete hack, but maybe that's OK. Let me know what you think.

That's good. We could also use RevsetAliasesMap::insert() and function_names().

That said, I think a comment like # Don't add default symbol aliases because ... in config/revsets.toml is good enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants