commit:     c4d6482f1869a7a06e41dd2a95eee700b82fe027
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 14 16:52:38 2017 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sat Jan 14 19:08:21 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c4d6482f

repoman: always add a newline if the message body is one line

The second line in a git commit message is supposed to be blank.
Also, use a regex to more exactly match a Field: value line.

Before:
  dev-libs/libfoo: fix another bug
  Package-Manager: Portage-2.3.3, Repoman-2.3.1

After:
  dev-libs/libfoo: fix another bug

  Package-Manager: Portage-2.3.3, Repoman-2.3.1

Acked-by: Zac Medico <zmedico <AT> gentoo.org>

 repoman/pym/repoman/actions.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/repoman/pym/repoman/actions.py b/repoman/pym/repoman/actions.py
index 58b00d4..6b0c645 100644
--- a/repoman/pym/repoman/actions.py
+++ b/repoman/pym/repoman/actions.py
@@ -6,6 +6,7 @@ import errno
 import io
 import logging
 import platform
+import re
 import signal
 import sys
 import tempfile
@@ -128,8 +129,9 @@ class Actions(object):
                                        myupdates, mymanifests, myremoved, 
mychanged, myautoadd,
                                        mynew, commitmessage)
 
-               lastline = commitmessage.splitlines()[-1]
-               if not ':' in lastline:
+               lines = commitmessage.splitlines()
+               lastline = lines[-1]
+               if len(lines) == 1 or re.match(r'^\S+:\s', lastline) is None:
                        commitmessage += '\n'
 
                commit_footer = self.get_commit_footer()

Reply via email to