diff mbox

[U-Boot,v2] patman: cover letter shows like 00/xx if more than 10 patches

Message ID 1428029477-17706-1-git-send-email-josh.wu@atmel.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Josh Wu April 3, 2015, 2:51 a.m. UTC
Make cover letter shows like 0/x, 00/xx and 000/xxx etc.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
---

Changes in v2:
- use math.log10() function instead

 tools/patman/patchstream.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Simon Glass April 5, 2015, 6:31 p.m. UTC | #1
On 2 April 2015 at 20:51, Josh Wu <josh.wu@atmel.com> wrote:
> Make cover letter shows like 0/x, 00/xx and 000/xxx etc.
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> ---
>
> Changes in v2:
> - use math.log10() function instead
>
>  tools/patman/patchstream.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass April 18, 2015, 10:20 p.m. UTC | #2
On 5 April 2015 at 12:31, Simon Glass <sjg@chromium.org> wrote:
> On 2 April 2015 at 20:51, Josh Wu <josh.wu@atmel.com> wrote:
>> Make cover letter shows like 0/x, 00/xx and 000/xxx etc.
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>>
>> Changes in v2:
>> - use math.log10() function instead
>>
>>  tools/patman/patchstream.py | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-x86/buildman, thanks!
diff mbox

Patch

diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index 8c3a0ec..6d3c41f 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -3,6 +3,7 @@ 
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+import math
 import os
 import re
 import shutil
@@ -468,8 +469,10 @@  def InsertCoverLetter(fname, series, count):
     prefix = series.GetPatchPrefix()
     for line in lines:
         if line.startswith('Subject:'):
-            # TODO: if more than 10 patches this should save 00/xx, not 0/xx
-            line = 'Subject: [%s 0/%d] %s\n' % (prefix, count, text[0])
+            # if more than 10 or 100 patches, it should say 00/xx, 000/xxx, etc
+            zero_repeat = int(math.log10(count)) + 1
+            zero = '0' * zero_repeat
+            line = 'Subject: [%s %s/%d] %s\n' % (prefix, zero, count, text[0])
 
         # Insert our cover letter
         elif line.startswith('*** BLURB HERE ***'):