Support git commit signing using OpenPGP
This Pull Request fixes/closes #97.
It changes the following:
- Add a new trait called
Sign - Implement
Signforgpgcommit signing via shellout- Users with a working signing setup will find that it just works in gitui as well
- Add entrypoints for all natively supported methods
- Add potential entrypoint for pure rust implementations behind a gitconfig value of
gitui.signing_methods
I followed the checklist:
- [x] I added unittests
- [x] I ran
make checkwithout errors - [x] I tested the overall application
- [ ] I added an appropriate item to the changelog
Todo:
- [x] Test in Windows ๐ช
- [ ] Documentation
- [ ] Draft an isolated integration test running in a container
Draft an isolated integration test running in a container
Since shellouts call out to actual system binaries, @extrawurst and I came up with the idea to create a test that runs in the isolation of a container. Inside of that environment, it could generate a GPG key and do an actual commit to verify the signature was created as expected.
Will attend to the failures in CI within the next days.
waiting for this feature ready
Looking into the CI errors again now.
๐ โ The previous error was caused by a doctest I added. The other unit tests prepare their environment, the doctest does not. Since I added it as documentation only, I deactivated the doctest and the CI run in my fork was good now: https://github.com/hendrikmaus/gitui/actions/runs/4221076989
@extrawurst if you'd approve another CI run here, thanks.
Hey just checking the status of this PR? I can test on macOS and windows easily if needed :)
Both would be appreciated, thank you.
Tested it on macOS. Authoring commits works fine, but some simple operations like amending & rewording the last commit don't work. I've created a PR with workarounds: https://github.com/hendrikmaus/gitui/pull/1.
๐ hello! Any movement on this by chance? Thanks!
๐ hello! Any movement on this by chance? Thanks!
Iโm also waiting for this feature
Havenโt had time to continue, but will do so in the beginning of ~~May~~ June (sry for the delay).
Will tackle these:
- [x] Fix amending and rewording, thanks @utkarshgupta137 for already preparing a change-set
- [ ] Align configuration with the existing pattern (in progress)
- [x] Test on Windows
- [ ] Documentation
- [ ] Integration test
Hey, how's the progress on this? :)
Can someone test a current build on a Windows environment? I'd appreciate that.
To test this, would we need to download this PR's code, compile, and run? Or is there some auto-generated binary for testing I should download somewhere?
At this point there are no pre-compiled binaries. So you have to download and compile it.
I compiled it with cargo install gitui and tried to run the binary from .cargo dir but it is showing me the same error. I might be doing something wrong...
PS: I don't have experience in working with Rust.
I reckon you compiled the master branch as that is the error that was shown before this initiative started. Here is the zip file of my branch on github: https://github.com/hendrikmaus/gitui/archive/refs/heads/gpg-commit-signing.zip
works like a charm on ventura๐
just want this pr to be merged as soon as possible
I compiled it with
cargo install gituiand tried to run the binary from .cargo dir but it is showing me the same error. I might be doing something wrong...PS: I don't have experience in working with Rust.
maybe install with command below?
cargo install --git https://github.com/hendrikmaus/gitui --branch gpg-commit-signing
@hendrikmaus works for me on windows 11 (built with rust using MSVC toolchain, GnuPG as program for signing)
- Password prompt appears correctly when signing is enabled by default
- Commits are in fact signed (verified with
git log --show-signature)
Thank you for the feedback, that is good news.
@extrawurst re configuration.
As we were talking about this the other day, did you take another look at the available approaches? I.e. .gitconfig file versus the gitui options?
Well, I installed it from the git repo and it definitely tries to sign now. However, I'm using my ssh key to sign rather than a gpg key and it says that's unsupported. Would this capability be difficult to add?
@damccull out of scope here, but the change-set already prepares an entry point for that in the code. There is another open issue about signing with ssh keys in https://github.com/extrawurst/gitui/issues/1149
Ah, thanks.
@extrawurst re configuration.
As we were talking about this the other day, did you take another look at the available approaches? I.e. .gitconfig file versus the gitui options?
I think it would be feasible to pass a new optional struct with the signing options down into the asyncgit crate from here: https://github.com/hendrikmaus/gitui/blob/24bb8ac57e2f7c8320eb4e6b75c8dc4739b6b7e0/src/components/commit.rs#L274
The asyncgit::sync::commit function has more than 40 call sites, mostly tests, that would need to be adjusted. The signatures of asyncgit::sync::reword and asyncgit::sync::amend would also be affected as they call commit.
I would propose something like Option<CommitConfig> to implement it open for extension. We might see the need to pass more configurations down to commit and I wouldn't want to limit it to only the signing options now. What do you think @extrawurst ?
Any updates on this?
an interesting catch: https://github.com/libgit2/libgit2/pull/6617 - seems like libgit2 starts supporting shell-out for ssh
Can't wait for this, is there a workaround as of right now?
Can't wait for this, is there a workaround as of right now?
My current workaround is to use gitui for all operations it can do except commit and push. I quit it, use Connor via cli, then push real quick since I'm already there.
My current workaround is to use gitui for all operations it can do except commit and push. I quit it, use Connor via cli, then push real quick since I'm already there.
Ah, so what I've been doing currently, All I've really been doing is commiting which is quite easy, will probably dwelve further into gitui once it supports gpgsigning.
