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

FR: Make the mine() revset builtin #1976

Closed
PhilipMetzger opened this issue Aug 4, 2023 · 5 comments
Closed

FR: Make the mine() revset builtin #1976

PhilipMetzger opened this issue Aug 4, 2023 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@PhilipMetzger
Copy link
Contributor

At the moment all users need to setup the revset alias by themselves, this is trivial but it should be builtin.

The alias looks like this:

# In config.toml
[revset-aliases]
'mine()' = 'author(your-name)' 

The implementation should look something like this:

impl RevSetExpression {
   // ...
    fn mine(self: &Rc<RevSetExpression>) -> Rc<RevSetExpression> {
    // Read the user.name field
    let author_name = ...;
    // ...
    Rc::new(RevsetExpression::filter(RevsetFilterPredicate::Author(
            author_name,
         )))
  } 

}

Then you need to add it to the builtins function map, without expecting arguments
https://github.com/martinvonz/jj/blob/85b66e43f06bd58045d991d047bd7c142fb09622/lib/src/revset.rs#L932-L946

Then you only need to add tests to finish your first contribution, don't forget to sign the CLA.

@PhilipMetzger PhilipMetzger added enhancement New feature or request good first issue Good for newcomers labels Aug 4, 2023
@PhilipMetzger PhilipMetzger changed the title FR: Make the revset mine() builtin FR: Make the mine() revset builtin Aug 4, 2023
@Dr-Emann
Copy link
Contributor

Dr-Emann commented Aug 9, 2023

I'm not sure how to get access to the overall jj config to get the author that's configured, as far as I can tell, there's not a way to currently get there from any of the arguments to RevsetFunction, but I could be missing something.

@PhilipMetzger
Copy link
Contributor Author

PhilipMetzger commented Aug 9, 2023

You'll need a to add a dependency on the cli crate, to get access to LayeredConfigs . See martin's answer

@martinvonz
Copy link
Member

You'll need a to add a dependency on the cli crate, to get access to LayeredConfigs .

We don't want dependencies from the lib crate to the CLI crate. See https://github.com/martinvonz/jj/blob/main/docs/technical/architecture.md#separation-of-library-from-ui.

I think we can instead pass in the current username into the revset::parse() function, much like the workspace_ctx argument we already pass to that function.

@emilykfox
Copy link
Contributor

mine() is now available. However, it aliases the user's email address instead of their name.

@PhilipMetzger
Copy link
Contributor Author

LGTM, thanks for implementing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants