[Libreoffice-commits] dev-tools.git: esc-reporting/esc-collect.py

Guilhem Moulin (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 19 16:08:05 UTC 2020


 esc-reporting/esc-collect.py |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 1520268a8c5511ad9c21980f1de5d3d8711fb1fe
Author:     Guilhem Moulin <guilhem at libreoffice.org>
AuthorDate: Mon Feb 17 05:20:28 2020 +0100
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Wed Feb 19 17:07:48 2020 +0100

    esc-collect: improve git calls
    
     * Use Python's subprocess module instead of os.system.  Other
       occurrences of the latter should probably be changed too, but that's
       perhaps for another patch. :-)
     * Use a pipe instead of dumping the entire(!) log output to a hardcoded
       file and postprocess it afterwards.  `git log` plays well with
       SIGPIPEs, there is no reason to dump the entire log if we're only
       interested in the handful most recent lines (the loop aborts as soon
       as log entries get too old).
     * Don't call `git fetch --all` immediately after `git pull`.  The
       latter has a `--all` flag too, so a single command is enough.
     * Silence `git pull`'s summary to avoid spamming us with cron execution
       reports :-)
     * Use `git -C $DIRECTORY` flag instead of calling `cd` in a subshell.
       (That flag exists was added to git 1.8.5 released in Nov 2013.)
    
    Change-Id: I588e333123a6523eb6df11e04bfd3958b3f59122
    Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/88841
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/esc-reporting/esc-collect.py b/esc-reporting/esc-collect.py
index 64584f9..b0adc1f 100755
--- a/esc-reporting/esc-collect.py
+++ b/esc-reporting/esc-collect.py
@@ -38,6 +38,7 @@ import datetime
 import json
 import xmltodict
 import requests
+from subprocess import check_call, Popen, PIPE
 from requests.auth import HTTPDigestAuth
 
 
@@ -667,15 +668,11 @@ def get_git(cfg):
                   '"committer": "%cn", "committer-email": "%ce" }'
       basedir = cfg['homedir'] + '../libreoffice/'
       if repo['git'] and cfg['platform'] == 'linux':
-        os.system('(cd ' + basedir + repo['dir'] + ';git pull -r;git fetch --all) > /dev/null')
-      os.system('(cd ' + basedir + repo['dir'] + ";git log --pretty=format:'" + useFormat + "') > /tmp/git.log")
-      fp = open('/tmp/git.log', encoding='utf-8')
-      while True:
+        check_call(["git", "-C", basedir + repo['dir'], "pull", "--quiet", "--rebase", "--all"])
+      p = Popen([ "git", "-C", basedir + repo['dir'], "log", "--pretty=format:" + useFormat ], stdout=PIPE)
+      for x in io.TextIOWrapper(p.stdout, encoding="utf-8"):
         # Json fails if there's a backslash somewhere in the git log
-        x = fp.readline().replace("\\", "/")
-        if x is None or x == '':
-          break
-        row = json.loads(x)
+        row = json.loads(x.replace("\\", "/"))
         row['repo'] = repo['name']
         key = repo['name'] + '_' + row['hash']
         if not key in rawList['commits']:


More information about the Libreoffice-commits mailing list