mirror of
https://github.com/zed-industries/zed.git
synced 2026-07-31 02:27:58 +00:00
Closes #61141 Follow-up https://github.com/zed-industries/zed/pull/58791 # Objective Currently after https://github.com/zed-industries/zed/pull/58791 landed, we now always ask for the gpg passphrase on every commit which is not ideal, since some people have a bigger **ttl** configured so they don't have/want to re-enter their passphrase everytime on every commit. So we should cache the signature so the user does not have to re-enter their passphrase everytime, which also fixes the case for unprotected keys which obviously don't have a passphrase. So we pre-check if we can sign the commit if so we should not ask for the passphrase at all. ## Solution The solution was also suggested inside this https://github.com/zed-industries/zed/issues/61141 issue, to first check if the signature was cached, if that is is the case use that to sign the commit. If that fails we should fallback to the loopback mode and Zed should prompt for your passphrase once and your signature should be cached again. ## Testing **The basic setup for gpg signing**: 1. Create a key `gpg --full-generate-key` 2. Run `git config --global user.signingkey <KEY ID>` 3. Run `git config --global commit.gpgsign true` 4. Run & copy result from `gpg --armor --export <KEY ID>` and submit your public key to github https://github.com/settings/gpg/new **Testing the new flow were the signature is cached**: 5. Run `gpgconf --reload gpg-agent` to reset cached signature 6. Make a change and try committing 7. See that it promts for your passphrase 8. enter passphrase 9. Make a change and try committing 10. Notice it does not re-promts for your passphrase ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [ ] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase **Before** (**Note** before you were prompted everytime when you commit) https://github.com/user-attachments/assets/0a967bb1-5eff-4224-9e9a-995e411f8d3a **After** (**Note** you are only prompted once and using the keychain after instead) https://github.com/user-attachments/assets/5eee6afb-5972-44d8-afdd-6416a189db32 --- **Note**: I used AI as an assistance to write this PR. Release Notes: - Git: Fixed the GPG signing passphrase prompt appearing on every commit even when gpg-agent had the passphrase cached or the key was unprotected. |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| LICENSE-GPL | ||