Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
20.94k stars 1.93k forks source link

Support for Signed Commits #1600

Open antonengelhardt opened 1 month ago

antonengelhardt commented 1 month ago

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) <xxx@icloud.com>": No secret key
[GNUPG:] INV_SGNR 9 Anton Engelhardt (aider) <xxx@icloud.com>
[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

fry69 commented 1 month ago

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

antonengelhardt commented 1 month ago

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.

paul-gauthier commented 1 month ago

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 "xxx@icloud.com`.

antonengelhardt commented 1 month ago

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 "xxx@icloud.com`.

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.

fry69 commented 1 month ago

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.

antonengelhardt commented 1 month ago

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