aider
aider copied to clipboard
Support for Signed Commits
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
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
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.
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]`.
Does
git commitwork 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.
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.
Could be. I have never worked with GitPython tbh. But this would be a nice add-on for everyone who uses gpgsign by default
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...
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
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.
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.
You can turn off modifications to the git author. See:
https://aider.chat/docs/git.html