[PATCH 2/2] git: Verify boolean values passed to sync-git-verify-commit-signature

Wynn Wolf Arbor <[email protected]>
Newsgroups gmane.linux.gentoo.portage.devel
Message-ID <[email protected]>
Currently, if 'sync-git-verify-commit-signature' is set to anything
other than 'yes', 'no', 'true', or 'false', its value is ignored
silently and nothing is verified because the option defaults to 'false'.

Introduce a check to CheckGitConfig that warns the user if their input
is invalid.

Closes: https://bugs.gentoo.org/703698
Signed-off-by: Wynn Wolf Arbor <[email protected]>
---
 lib/portage/sync/modules/git/__init__.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/portage/sync/modules/git/__init__.py b/lib/portage/sync/modules/git/__init__.py
index 270d97186..913e391cb 100644
--- a/lib/portage/sync/modules/git/__init__.py
+++ b/lib/portage/sync/modules/git/__init__.py
@@ -14,6 +14,7 @@ class CheckGitConfig(CheckSyncConfig):
 	def __init__(self, repo, logger):
 		CheckSyncConfig.__init__(self, repo, logger)
 		self.checks.append('check_depth')
+		self.checks.append('check_verify_commit_signature')
 
 	def check_depth(self):
 		for attr in ('clone_depth', 'sync_depth'):
@@ -33,6 +34,16 @@ class CheckGitConfig(CheckSyncConfig):
 			else:
 				setattr(self.repo, attr, d)
 
+	def check_verify_commit_signature(self):
+		v = self.repo.module_specific_options.get(
+			'sync-git-verify-commit-signature', 'false')
+
+		if v not in ['yes', 'no', 'true', 'false']:
+			writemsg_level("!!! %s\n" %
+				_("sync-git-verify-commit-signature not one of: %s")
+				% ('{yes, no, true, false}'),
+				level=self.logger.ERROR, noiselevel=-1)
+
 
 module_spec = {
 	'name': 'git',
-- 
2.27.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.