Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

git: Add ability to PGP sign commits #920

Merged
merged 5 commits into from
Aug 17, 2018
Merged

git: Add ability to PGP sign commits #920

merged 5 commits into from
Aug 17, 2018

Conversation

vancluever
Copy link
Contributor

This adds the ability to sign commits by adding the SignKey field to
CommitOptions. If present, the commit will be signed during the
WorkTree.Commit call.

The supplied SignKey must already be decrypted by the caller.

Signed-off-by: Chris Marchesi <[email protected]>


There is also a small bugfix in here as well that was affecting the ability to sign commits:

plumbing: object, Don't add new line at end of commit signature

The way that commit signatures were being written out was causing an
extra newline to be written at the end of the commit when the message
encoding was already taking care of this. Ultimately, this results in a
corrupt object, rendering the object unverifiable with the signature in
the commit.

Signed-off-by: Chris Marchesi <[email protected]>

The way that commit signatures were being written out was causing an
extra newline to be written at the end of the commit when the message
encoding was already taking care of this. Ultimately, this results in a
corrupt object, rendering the object unverifiable with the signature in
the commit.

Signed-off-by: Chris Marchesi <[email protected]>
This adds the ability to sign commits by adding the SignKey field to
CommitOptions. If present, the commit will be signed during the
WorkTree.Commit call.

The supplied SignKey must already be decrypted by the caller.

Signed-off-by: Chris Marchesi <[email protected]>
@vancluever
Copy link
Contributor Author

Looks like tests are failing due to use of strings.Builder.

I'll switch this up to using bytes.Buffer to maintain the backwards compatibility with Go 1.9.

This was added in Go 1.10 and is not supported on Go 1.9. Switched to
bytes.Buffer to ensure compatibility.

Signed-off-by: Chris Marchesi <[email protected]>
This will not work for a signed commit as with the GPG signature being a
part of the commit, the hash is now non-deterministic.

Verification of the commit is done through the validation of the
signature.

Signed-off-by: Chris Marchesi <[email protected]>
I'm hoping this helps get codecov to a tolerable delta. :)

Signed-off-by: Chris Marchesi <[email protected]>
@mcuadros mcuadros requested review from jfontan and smola August 17, 2018 06:43
Copy link
Collaborator

@smola smola left a comment

Choose a reason for hiding this comment

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

Other than CI failing, looks good!

Just a minor comment on formatting.

encoded := &plumbing.MemoryObject{}
if err := commit.Encode(encoded); err != nil {
return "", err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add spaces after each if block (this is a convention that we generally follow all over go-git codebase).

@smola
Copy link
Collaborator

smola commented Aug 17, 2018

I triggered manually the failing job in CI. It is an intermittent failure, not related to this PR.

@mcuadros mcuadros merged commit 7b6c126 into src-d:master Aug 17, 2018
@vancluever
Copy link
Contributor Author

Thanks @smola! I'll keep that in mind for some future tagging work I'm working on.

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

Successfully merging this pull request may close these issues.

4 participants