Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH v3 3/3] repoman: Verify commit messages when using EDITOR
Date: Mon, 19 Feb 2018 15:01:19
Message-Id: 20180219150057.20338-3-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v3 1/3] repoman: Add commit message verification by "Michał Górny"
1 ---
2 repoman/pym/repoman/actions.py | 22 +++++++++++++++++++---
3 1 file changed, 19 insertions(+), 3 deletions(-)
4
5 diff --git a/repoman/pym/repoman/actions.py b/repoman/pym/repoman/actions.py
6 index cd954223a..8e23322c8 100644
7 --- a/repoman/pym/repoman/actions.py
8 +++ b/repoman/pym/repoman/actions.py
9 @@ -129,7 +129,23 @@ class Actions(object):
10 else:
11 sys.exit(1)
12 else:
13 - commitmessage = self.get_new_commit_message(qa_output)
14 + commitmessage = None
15 + msg_qa_output = qa_output
16 + initial_message = None
17 + while True:
18 + commitmessage = self.get_new_commit_message(
19 + msg_qa_output, commitmessage)
20 + res, expl = self.verify_commit_message(commitmessage)
21 + if res:
22 + break
23 + else:
24 + full_expl = '''Issues with the commit message were found. Please fix it or remove
25 +the whole commit message to abort.
26 +
27 +''' + expl
28 + msg_qa_output = (
29 + [' %s\n' % x for x in full_expl.splitlines()]
30 + + qa_output)
31
32 commitmessage = commitmessage.rstrip()
33
34 @@ -577,8 +593,8 @@ class Actions(object):
35 prefix = "/".join(self.scanner.reposplit[1:]) + ": "
36 return prefix
37
38 - def get_new_commit_message(self, qa_output):
39 - msg_prefix = self.msg_prefix()
40 + def get_new_commit_message(self, qa_output, old_message=None):
41 + msg_prefix = old_message or self.msg_prefix()
42 try:
43 editor = os.environ.get("EDITOR")
44 if editor and utilities.editor_is_executable(editor):
45 --
46 2.16.2