From 093fdb6587bba081c4d34eb9ea500149b1090280 Mon Sep 17 00:00:00 2001 From: bijia Date: Thu, 28 Nov 2013 09:19:22 +0800 Subject: Add reviewers automatically from project's git config The `review.URL.autocopy` setting sends email notification to the named reviewers, but does not add them as reviewer on the uploaded change. Add a new setting `review.URL.autoreviewer`. The named reviewers will be added as reviewer on the uploaded change. Change-Id: I3fddfb49edf346f8724fe15b84be8c39d43e7e65 Signed-off-by: bijia --- subcmds/upload.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'subcmds/upload.py') diff --git a/subcmds/upload.py b/subcmds/upload.py index 526dcd57..e2fa261e 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py @@ -89,6 +89,11 @@ to "true" then repo will assume you always answer "y" at the prompt, and will not prompt you further. If it is set to "false" then repo will assume you always answer "n", and will abort. +review.URL.autoreviewer: + +To automatically append a user or mailing list to reviews, you can set +a per-project or global Git option to do so. + review.URL.autocopy: To automatically copy a user or mailing list to all uploaded reviews, @@ -293,14 +298,20 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ self._UploadAndReport(opt, todo, people) - def _AppendAutoCcList(self, branch, people): + def _AppendAutoList(self, branch, people): """ + Appends the list of reviewers in the git project's config. Appends the list of users in the CC list in the git project's config if a non-empty reviewer list was found. """ - name = branch.name project = branch.project + + key = 'review.%s.autoreviewer' % project.GetBranch(name).remote.review + raw_list = project.config.GetString(key) + if not raw_list is None: + people[0].extend([entry.strip() for entry in raw_list.split(',')]) + key = 'review.%s.autocopy' % project.GetBranch(name).remote.review raw_list = project.config.GetString(key) if not raw_list is None and len(people[0]) > 0: @@ -323,7 +334,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ for branch in todo: try: people = copy.deepcopy(original_people) - self._AppendAutoCcList(branch, people) + self._AppendAutoList(branch, people) # Check if there are local changes that may have been forgotten if branch.project.HasChanges(): -- cgit v1.2.3-54-g00ecf