Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for authorlist

This makes it possible to enforce both the committer name and the author name,
while not enforcing them to actually be the same. Meaning one committer
can commit a patch authored by another one.

As asked for by Peter E.
  • Loading branch information...
commit df4138f833b3471d9eb32966cb356fe5081d12f5 1 parent 6da709c
@mhagander authored
Showing with 23 additions and 13 deletions.
  1. +6 −0 README.rst
  2. +17 −13 policyenforce.py
View
6 README.rst
@@ -120,6 +120,12 @@ committerlist
config file. This ensures that committers don't accidentally use a
badly configured client. All the commiters should be listed in the
[committers] section, in the format User Name=email.
+authorlist
+ Enforce that the username and email of the author is listed in the
+ config file. It uses the same list of users as the committerlist,
+ thus it should be listed in [committers]. This allows one committer
+ to push things made by another committer, while still making sure
+ all authors are registered.
nolightweighttags
Enforce that there are no lightweight tags - only tags carrying
a description are allowed.
View
30 policyenforce.py
@@ -8,7 +8,7 @@
# Note: the script (not surprisingly) uses the git commands in pipes, so git
# needs to be available in the path.
#
-# Copyright (C) 2010-2011 PostgreSQL Global Development Group
+# Copyright (C) 2010-2013 PostgreSQL Global Development Group
# Author: Magnus Hagander <magnus@hagander.net>
#
# Released under the PostgreSQL license
@@ -149,19 +149,23 @@ def check_policies(self):
if self._enforce("committerlist"):
# Enforce specific committer listed in config file.
- # We do this by splitting the name again, and doing a lookup
- # match on that.
- m = re.search('^([a-zA-Z0-9. ]+) <([^>]+)>', self.committer)
- if not m:
- raise Exception("Committer '%s' for commit %s does not follow format rules." % (self.committer, self.commitid))
- if not c.has_option('committers', m.group(1)):
- self._policyfail("Committer %s not listed in committers section" % m.group(1))
- if not c.get('committers', m.group(1)) == m.group(2):
- self._policyfail("Committer %s has wrong email (%s, should be %s)" % (
- m.group(1), m.group(2), c.get('committers', m.group(1))))
- # Currently no policy for "authorlist" - expect committerequalsauthor+committerlist to be
- # used in those cases.
+ self.enforce_user(self.committer, 'Committer')
+ if self._enforce("authorlist"):
+ # Enforce specific author is listed in config file (as committer).
+ self.enforce_user(self.author, 'Author')
+
+ def enforce_user(self, user, usertype):
+ # We do this by splitting the name again, and doing a lookup
+ # match on that.
+ m = re.search('^([a-zA-Z0-9. ]+) <([^>]+)>', user)
+ if not m:
+ raise Exception("%s '%s' for commit %s does not follow format rules." % (usertype, user, self.commitid))
+ if not c.has_option('committers', m.group(1)):
+ self._policyfail("%s %s not listed in committers section" % (usertype, m.group(1)))
+ if not c.get('committers', m.group(1)) == m.group(2):
+ self._policyfail("%s %s has wrong email (%s, should be %s)" % (
+ usertype, m.group(1), m.group(2), c.get('committers', m.group(1))))
class Tag(PolicyObject):
def __init__(self, ref, name):
Please sign in to comment.
Something went wrong with that request. Please try again.