aider icon indicating copy to clipboard operation
aider copied to clipboard

Support for Signed Commits

Open antonengelhardt opened this issue 1 year ago • 6 comments

Issue

I have git config commit.gpgSign set to true.

Aider fails to create commits because they cannot be signed:

Unable to commit: Cmd('git') failed due to: exit code(128)
  stderr: 'error: gpg failed to sign the data:
gpg: skipped "Anton Engelhardt (aider) <[email protected]>": No secret key
[GNUPG:] INV_SGNR 9 Anton Engelhardt (aider) <[email protected]>
[GNUPG:] FAILURE sign 17
gpg: signing failed: No secret key

fatal: failed to write commit object'

Is there any way to fix this apart from turning the git flag off or turning auto-commits off?

Version and model info

v0.56.0

antonengelhardt avatar Sep 19 '24 19:09 antonengelhardt

Thank you for filing this issue.

You can try committing manually with /run git add . && git commit -m "commit message" or similar.

Otherwise have a look at GitPython, aider uses this library behind the scenes -> https://github.com/gitpython-developers/GitPython

fry69 avatar Sep 19 '24 19:09 fry69

Thanks! I think for now i will turn the auto-commits off and experiment with aider for a bit. Just thought this might be worth flagging. Potentially something could be configured to let aider know, that i want my commits signed.

antonengelhardt avatar Sep 20 '24 08:09 antonengelhardt

Does git commit work for you in the terminal outside of aider? It appears to be complaining that gpg can't find the key for "[email protected]`.

paul-gauthier avatar Sep 20 '24 19:09 paul-gauthier

Does git commit work for you in the terminal outside of aider? It appears to be complaining that gpg can't find the key for "[email protected]`.

Yes. I have installed pinentry in case it asks for a password. But the key is definitely there even though it says it can't find it.

antonengelhardt avatar Sep 21 '24 05:09 antonengelhardt

The only reason I can think of why GitPython inside aider cannot see your GPG key is that aider is running in an isolated environment (container) or something like that. It that a possibility?

Now that I think about it, it may also be possible that GitPython lacks modern functionality for accessing GPG keys, which the native git binaries have no problem with.

fry69 avatar Sep 21 '24 05:09 fry69

Could be. I have never worked with GitPython tbh. But this would be a nice add-on for everyone who uses gpgsign by default

antonengelhardt avatar Sep 23 '24 11:09 antonengelhardt

In lieu of full signing support, would be great to have an option for aider to pass --no-gpg-sign so it can at least successfully create commits...

max-sixty avatar Dec 10 '24 08:12 max-sixty

I think this is relevant for this issue, as it explains how to use GitPython to sign commits: https://github.com/nautilus-cyberneering/pygithub/blob/main/docs/how_to_sign_commits_using_the_gitpython_package.md

ziodave avatar Dec 29 '24 15:12 ziodave

For anyone who encounters this issue in the future:

The problem appears to be that aider, by default, changes the git author and committer by adding "aider" to the name. You can fix this by using --no-attribute-author --no-attribute-committer in the command line or by setting the corresponding config values in another way. This fixed the gpg signing issue for me.

psyho avatar Feb 21 '25 10:02 psyho

The issue is that aider does change the author/committer and there's no gpg keys for that author.

I was able to resolve the above by adding a new gpg key with a comment field set to aider, so that my keys title is the same format as the commit author eg Anton Engelhardt (aider) <[email protected]>. I'm more than happy to use separate set of keys for aider.

I don't think that above issue has anything to do with aider itself or the used libraries.

andycandy-dev avatar Mar 28 '25 18:03 andycandy-dev

You can turn off modifications to the git author. See:

https://aider.chat/docs/git.html

paul-gauthier avatar Mar 28 '25 19:03 paul-gauthier