-
-
Notifications
You must be signed in to change notification settings - Fork 574
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 support for GPG signing commits #219
Conversation
4fd93df
to
179d6d4
Compare
@grantbdev thanks for looking into this! Can we maybe learn something from |
@extrawurst From what I can tell, the libraries tests things at low enough of a level that typically the config isn't a factor. In Setting values during a test like this will impact the execution:
|
4af293c
to
519547d
Compare
8912c4d
to
02284d3
Compare
7d84c89
to
9077deb
Compare
9077deb
to
463bc91
Compare
@grantbdev what's the status on this? |
@extrawurst Sorry, definitely got distracted from working on this. I know I was getting discouraged that it seems system (non-Rust) libraries were needed to get this to work and I was having trouble getting it set up correctly for the Windows CI build. I have a feeling this could be too burdensome to the project overall to maintain and I'm uncertain about whether it will negatively impact users who don't care about GPG signing, but let me know what you think. My gut feeling is that I know that is a pretty radical departure from the current design of your project, but I'm curious if you have considered or experimented with that approach at all. I also wonder if it's something that could be used in some parts rather than a complete overhaul of not using |
@grantbdev it would be a shame to see this bitrot away. but I agree adding big bunch of system dependencies is a bit of a downer. did you look into https://gitlab.com/sequoia-pgp/sequoia if that might be a solution here? |
@extrawurst I don't think I previously looked at Sequoia, so thanks for linking. I took a short spin at it and from what I can tell I don't think it well help. I think it's generally more low-level than what GPGme provides and I'm not familiar with the implementation details. For instance, I am not sure how to replicate finding a public key from the local keychain which is the first step in using the user's Git GPG settings. |
81a8849
to
f84f6f4
Compare
Hey @extrawurst and @grantbdev, You can create commit objects with I would also propose signing commits directly with the git binary because it’s more convenient to configure it and reduce dependencies. Since People who sign commits already have these tools installed on their machine, it works with the git binary properly. Referenceshttps://git-scm.com/docs/git-commit-tree |
@solidnerd This PR is effectively abandoned by me at this point. You're welcome to take your own stab at it and use any of my commits if they are helpful. My understanding was |
Just if that helps. I'm gitg maintainer and use this PR as reference to confirm steps needed to sign a commit. libgit2 is agnostic about signing a commit, that's why it offers a The tricky part is I just merge it: https://gitlab.gnome.org/GNOME/gitg/-/merge_requests/198 and libgit2-glib (glib wrapper around libgit2) related PR is linked there. |
@nigelatdas that's the approach gitg will take. libgit2 has different scopes and goals than git GUI |
Overview
This PR is an initial stab at resolving #97. This is a recreation of #218, which I accidentally created without marking as a draft PR and I was unable to set it back so I decided to close it.
With these changes, I was able to create this PR's commits signed with
gitui
:Details
Unfortunately,
libgit2
appears to not provide an interface for creating signed commits as friendly as standard commit creation so there is a lot of code added. The GPG signing must be done manually which brings in dependencies forgpgme
. Unlike standard commit creation, there is not an option to automatically updateHEAD
so it must be done manually when after creating a signed commit. When dealing with a newly initialized repo, this means the default branch has to be created as well! There is no official documentation creating signed commits withlibgit2
, so credit goes to rust-lang/git2-rs#507 for figuring it out.I am not sure how test suite should handle this new functionality. The main conditional is currently determined by the user's git config option, so on my computer it will always use the GPG signing. We could add extra tests and manage whether GPG signing should be on for each one or try to run the entire suite with GPG signing on and off. The main commit tests are working, but locally I am getting ~4-6 failures each time. Here is a sample run:
The invalid UTF-8 failures seem to happen every time. There is a point in the GPG commit logic that will panic if the message contains invalid UTF-8 and I guess that differs from the standard commit logic? I'm not sure how that should be resolved other than having different expectations with and without the GPG signing feature.
The rest are random tests failing each run, pointing to gcrypt or Pinentry and saying it couldn't allocate memory. This appears to only happen when the tests are run in parallel by default.
cargo test -- --test-threads=1
will eliminate the random failures.