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

Add jj sign command #3142

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

julienvincent
Copy link
Contributor

@julienvincent julienvincent commented Feb 25, 2024

This is a continuation from #3007 and #2728 which adds in the jj sign command that was split out of the original PR.


Some outstanding comments I am carrying over from #3007:

Checklist

  • 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

julienvincent and others added 4 commits February 25, 2024 14:50
Currently the TestSigningBackend can only be used from the test gradle.
This makes it hard to build command tests for signing commands as they
are tested against the CLI interface directly.

This commit renames the TestSigningBackend struct to MockSigningBackend
and moves it to the lib module, allowing us to configure it via config
and therefore use it from command tests.
Cannot make it accept multiple revisions easily, that'd have to be done
with a rebaser
pub fn cmd_sign(ui: &mut Ui, command: &CommandHelper, args: &SignArgs) -> Result<(), CommandError> {
let mut workspace_command = command.workspace_helper(ui)?;

let commit = workspace_command.resolve_single_rev(&args.revision)?;

Choose a reason for hiding this comment

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

would be nice to accept multiple revs

Copy link
Contributor

Choose a reason for hiding this comment

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

Descendants of rewritten commits (and signing is rewriting) get rebased, so if one of the revisions is a descendant of another there are issues you'd need to figure out how to avoid.

Another thing is a rebase optimisation that's needed for instances where you wan't to sign a range of commits - currently (if you do it in a loop in a shell, I guess) if you sign 10 commits you'd have 45 (ish? should be a triangle, n(n-1)/2) useless commits created from all the rebases.

So initially we decided to at least have a single-revision sign.

Also technically any rewriting command with --sign global flag is a sign.
Hm, hah, a noop rebase with --sign should be the rebase optimisation I was talking about above, interesting

Copy link
Member

Choose a reason for hiding this comment

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

I hope to make it easier to do such transformations while rebasing. It's just been hard to find time for it. The idea is that we'll something similar to rebase_descendants() but instead transform_descendants(callback) where the callback gets a CommitBuilder populated with the default values (so rebase_descendants will be transform_descendants(|_|) {}).

@walking-octopus
Copy link

Had there been any progress on this issue?

@julienvincent
Copy link
Contributor Author

julienvincent commented Apr 18, 2024

@walking-octopus No not this specifically. I have had a patch of very busy weeks and haven't had a chance to work on this stuff.

The sig verification PR has had the most recent work done: #3141

Are you specifically wanting this jj sign command or are you more wanting general commit signing? If the latter, this has already landed in jj version 0.15.0

@walking-octopus
Copy link

Are you specifically wanting this jj sign command or are you more wanting general commit signing? If the latter, this has already landed in jj version 0.15.0

Oh, I now see. Sorry for wasting time... sign-all does solve my use-case.

Still, it would certainly be nice to display the signing information within jj as well as have a dedicated command for those who may prefer it.

Once again, thank you so much for working on this! I've just tried jj, and it already looks so much more intuitive, flexible, and infinity less migraine inducing. I just wish the Git interop gets better in places.

@martinvonz
Copy link
Member

I just wish the Git interop gets better in places.

Feel free to file bug reports or feature requests when you notice anything.

@eopb eopb mentioned this pull request Apr 25, 2024
pylbrecht pushed a commit to pylbrecht/jj that referenced this pull request Nov 1, 2024
pylbrecht pushed a commit to pylbrecht/jj that referenced this pull request Nov 1, 2024
pylbrecht pushed a commit to pylbrecht/jj that referenced this pull request Nov 1, 2024
pylbrecht pushed a commit to pylbrecht/jj that referenced this pull request Nov 1, 2024
Changes were taken from jj-vcs#3142 and slightly modified.
pylbrecht pushed a commit to pylbrecht/jj that referenced this pull request Nov 8, 2024
pylbrecht pushed a commit to pylbrecht/jj that referenced this pull request Nov 8, 2024
Changes were taken from jj-vcs#3142 and slightly modified.
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.

5 participants