signing: allow disabling by setting backend to "none"

We don't seem to have a way to override the config to disable
signing. This patch lets you do that by setting
`signing.backend="none"`.
This commit is contained in:
Martin von Zweigbergk 2024-09-05 17:27:49 -07:00 committed by Martin von Zweigbergk
parent 8f603f1a9c
commit fee706dfea
3 changed files with 6 additions and 2 deletions

View file

@ -473,7 +473,8 @@
"backend": {
"type": "string",
"enum": ["gpg", "ssh"],
"description": "The backend to use for signing commits"
"description": "The backend to use for signing commits. The string `none` disables signing.",
"default": "none"
},
"key": {
"type": "string",

View file

@ -776,6 +776,8 @@ GnuPG or SSH signing keys.
To do this you need to configure a signing backend.
Setting the backend to `"none"` disables signing.
### GnuPG Signing
```toml

View file

@ -245,7 +245,8 @@ impl UserSettings {
// separate from sign_settings as those two are needed in pretty different
// places
pub fn signing_backend(&self) -> Option<String> {
self.config.get_string("signing.backend").ok()
let backend = self.config.get_string("signing.backend").ok()?;
(backend.as_str() != "none").then_some(backend)
}
pub fn sign_settings(&self) -> SignSettings {