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

Support ssh signing [fixes #123] #136

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jeremy-w
Copy link

@jeremy-w jeremy-w commented Apr 17, 2024

This mirrors the logic in git's sign_buffer_ssh() function in order to support signing commits with ssh keys.

The test assumes an ssh-agent is running. It heavily mirrors test_gpgsign, but omits the tests for argument/config handling around whether or not to sign.

[fixes #123]

Updated tox.ini to pass SSH_AUTH_SOCK through to the test env.
This assumes ssh-agent is already running.
This enables cleaning up the ssh-add operation when the test finishes.
@charettes
Copy link

charettes commented May 14, 2024

If it can be of any help, I've been using this feature branch to successfully sign my commits for the past few days without issues.

Thanks for the patch @jeremy-w 🙇

@olmokramer
Copy link

I tried this patch but couldn't get it to work because I'm using gpg.ssh.defaultKeyCommand to get the key to use for signing, but it is not used in this PR. I'm getting the following error:

Traceback (most recent call last):
  File "/nix/store/w12qszjhngb8a4fi7h8jjhyllaq3as3c-python3.11-git-revise-0.7.0/bin/.git-revise-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/w12qszjhngb8a4fi7h8jjhyllaq3as3c-python3.11-git-revise-0.7.0/lib/python3.11/site-packages/gitrevise/tui.py", line 264, in main
    inner_main(args, repo)
  File "/nix/store/w12qszjhngb8a4fi7h8jjhyllaq3as3c-python3.11-git-revise-0.7.0/lib/python3.11/site-packages/gitrevise/tui.py", line 244, in inner_main
    staged = repo.index.commit(message=b"<git index>")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/w12qszjhngb8a4fi7h8jjhyllaq3as3c-python3.11-git-revise-0.7.0/lib/python3.11/site-packages/gitrevise/odb.py", line 904, in commit
    return self.repo.new_commit(self.tree(), [parent], message)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/w12qszjhngb8a4fi7h8jjhyllaq3as3c-python3.11-git-revise-0.7.0/lib/python3.11/site-packages/gitrevise/odb.py", line 317, in new_commit
    body += self.sign_buffer(body + body_tail)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/w12qszjhngb8a4fi7h8jjhyllaq3as3c-python3.11-git-revise-0.7.0/lib/python3.11/site-packages/gitrevise/odb.py", line 347, in sign_buffer
    key_file_context_manager = open(key_id, "rb")
                               ^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: b'Olmo Kramer <redacted@example.com>'

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.

Commit signing does not support SSH signatures
3 participants