repoman: say Git >=1.7.9 needed for signed commit
authorZac Medico <zmedico@gentoo.org>
Mon, 5 Mar 2012 00:48:41 +0000 (16:48 -0800)
committerZac Medico <zmedico@gentoo.org>
Mon, 5 Mar 2012 00:54:39 +0000 (16:54 -0800)
bin/repoman

index bcb48e464a8de69d4540a0aa5369ca7c169aad44..3f16603f83b9a52d020e71511395d2dfc37ce9c4 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/python -O
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # Next to do: dep syntax checking in mask files
@@ -936,6 +936,20 @@ def vcs_files_to_cps(vcs_file_iter):
 
        return frozenset(modified_cps)
 
+def git_supports_gpg_sign():
+       status, cmd_output = \
+               subprocess_getstatusoutput("git --version")
+       cmd_output = cmd_output.split()
+       if cmd_output:
+               version = re.match(r'^(\d+)\.(\d+)\.(\d+)', cmd_output[-1])
+               if version is not None:
+                       version = [int(x) for x in version.groups()[1:]]
+                       if version[0] > 1 or \
+                               (version[0] == 1 and version[1] > 7) or \
+                               (version[0] == 1 and version[1] == 7 and version[2] >= 9):
+                               return True
+       return False
+
 def dev_keywords(profiles):
        """
        Create a set of KEYWORDS values that exist in 'dev'
@@ -2772,6 +2786,13 @@ else:
                        else:
                                retval = spawn(commit_cmd, env=os.environ)
                                if retval != os.EX_OK:
+
+                                       if repo_config.sign_commit and vcs == 'git' and \
+                                               not git_supports_gpg_sign():
+                                               # Inform user that newer git is needed (bug #403323).
+                                               logging.error(
+                                                       "Git >=1.7.9 is required for signed commits!")
+
                                        writemsg_level(("!!! Exiting on %s (shell) " + \
                                                "error code: %s\n") % (vcs, retval),
                                                level=logging.ERROR, noiselevel=-1)