From fee706dfea2de2353dc1c91bb85fa795b1382e52 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 5 Sep 2024 17:27:49 -0700 Subject: [PATCH] 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"`. --- cli/src/config-schema.json | 3 ++- docs/config.md | 2 ++ lib/src/settings.rs | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/src/config-schema.json b/cli/src/config-schema.json index 7b4658e42..95e244aaf 100644 --- a/cli/src/config-schema.json +++ b/cli/src/config-schema.json @@ -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", diff --git a/docs/config.md b/docs/config.md index 33f9c4062..82487f1ae 100644 --- a/docs/config.md +++ b/docs/config.md @@ -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 diff --git a/lib/src/settings.rs b/lib/src/settings.rs index 58e074884..64e33be26 100644 --- a/lib/src/settings.rs +++ b/lib/src/settings.rs @@ -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 { - 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 {