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

Re-roll of GPG commit signing #94

Merged
merged 3 commits into from
Oct 3, 2021
Merged

Conversation

krobelus
Copy link
Contributor

@krobelus krobelus commented Jul 30, 2021

This is #73 with review comments applied and two behavior changes.

(the broken Mac tests were pytest-dev/pytest#5802)

krobelus and others added 2 commits August 3, 2021 00:11
GPG-sign commits if option -S/--gpg-sign is given, or if configurations
revise.gpgSign or commit.gpgSign are set to true.

Unlike Git, we do not support passing the key ID as argument.  Git's
way of accepting this optional argument is a bit weird.  It would be
awkward to try to support the same with argparse.  So it's probably
best to use a separate argument for the key ID in future.

For now, the key ID is taken from Git configuration (user.signingKey)
or the committer signature as fallback.

A call of `git-revise COMMIT --gpg-sign` w/o any changes in the index
causes creation of GPG commit signatures for all commits since COMMIT.

Conversely, if GPG signing is disabled, git-revise will remove
the signature, even if the commits were not modified otherwise.
So adding/removing a signature is just another modification, like
rewording/rebasing. This logic is applied to all commits in the
todo-list.

The test is a bit large, but the pieces are mostly independen.  Maybe
we should share the GPG initialization somehow?

Closes mystor#46
Closes mystor#73

Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
Signed-off-by: Nicolas Schier <nicolas@fjasle.eu>
Copy link
Owner

@mystor mystor left a comment

Choose a reason for hiding this comment

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

Thanks for the patches and sorry for the slow reviews!

@mystor mystor merged commit 06e9126 into mystor:main Oct 3, 2021
check=True,
)
except CalledProcessError as gpg:
print(gpg.stderr.decode(), file=sys.stderr, end="")
Copy link
Contributor

Choose a reason for hiding this comment

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

This access to gpg.stderr will never work: if run() throws, gpg will not have been assigned a value other than the None above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, I see now that gpg is aliased to the caught exception itself!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

heh, that's pretty clever 😮

@pytest.fixture
def short_tmpdir():
with tempfile.TemporaryDirectory() as tdir:
yield py.path.local(tdir)
Copy link
Contributor

Choose a reason for hiding this comment

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

py.path is deprecated. Should this just use from pathlib import Path which is used elsewhere in this project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I didn't know! I remember I was just glad to get the macOS tests working somehow..

main(["HEAD~~", "--gpg-sign"])
assert repo.get_commit("HEAD~~").gpgsig is not None
assert repo.get_commit("HEAD~").gpgsig is not None
assert repo.get_commit("HEAD").gpgsig is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

Something concerning about these tests: they only check round-tripping of gitrevise's signature parsing/generation. There are no tests with git verify-commit, for example, to demonstrate that the signature is formatted as git itself expects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we should definitely have at least one test that shows that we produce/consume the same signatures as Git.

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.

3 participants