Re: [gentoo-portage-dev] [PATCH v2] repoman: always add a newline if the message body is one line

2017-01-14 Thread Zac Medico
On 01/14/2017 11:00 AM, Mike Gilbert wrote:
> 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
> ---
>  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 58b00d494..6b0c6459d 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()
> 

LGTM. Thanks!
-- 
Thanks,
Zac



[gentoo-portage-dev] [PATCH v2] repoman: always add a newline if the message body is one line

2017-01-14 Thread Mike Gilbert
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
---
 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 58b00d494..6b0c6459d 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()
-- 
2.11.0




Re: [gentoo-portage-dev] [PATCH] repoman: always add a newline if the message body is one line

2017-01-14 Thread Mike Gilbert
On Sat, Jan 14, 2017 at 1:11 PM, Zac Medico  wrote:
> On 01/14/2017 08:58 AM, Mike Gilbert wrote:
>> The second line in a git commit message is supposed to be blank.
>>
>> 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
>> ---
>>  repoman/pym/repoman/actions.py | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/repoman/pym/repoman/actions.py b/repoman/pym/repoman/actions.py
>> index 58b00d494..82c76b2fb 100644
>> --- a/repoman/pym/repoman/actions.py
>> +++ b/repoman/pym/repoman/actions.py
>> @@ -128,8 +128,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 not ':' in lastline:
>
> Maybe a regular expression would be better, like this:
>
>if len(lines) == 1 or re.match(r'^\S+:\s', lastline) is None:
>

Sure, I'll make that change (and add the re import).



Re: [gentoo-portage-dev] [PATCH] repoman: always add a newline if the message body is one line

2017-01-14 Thread Zac Medico
On 01/14/2017 08:58 AM, Mike Gilbert wrote:
> The second line in a git commit message is supposed to be blank.
> 
> 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
> ---
>  repoman/pym/repoman/actions.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/repoman/pym/repoman/actions.py b/repoman/pym/repoman/actions.py
> index 58b00d494..82c76b2fb 100644
> --- a/repoman/pym/repoman/actions.py
> +++ b/repoman/pym/repoman/actions.py
> @@ -128,8 +128,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 not ':' in lastline:

Maybe a regular expression would be better, like this:

   if len(lines) == 1 or re.match(r'^\S+:\s', lastline) is None:


>   commitmessage += '\n'
>  
>   commit_footer = self.get_commit_footer()
> 


-- 
Thanks,
Zac



[gentoo-portage-dev] [PATCH] repoman: always add a newline if the message body is one line

2017-01-14 Thread Mike Gilbert
The second line in a git commit message is supposed to be blank.

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
---
 repoman/pym/repoman/actions.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/repoman/pym/repoman/actions.py b/repoman/pym/repoman/actions.py
index 58b00d494..82c76b2fb 100644
--- a/repoman/pym/repoman/actions.py
+++ b/repoman/pym/repoman/actions.py
@@ -128,8 +128,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 not ':' in lastline:
commitmessage += '\n'
 
commit_footer = self.get_commit_footer()
-- 
2.11.0