bin/check-missing-unittests.py |   33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

New commits:
commit aa5fdd39570004df0a8e89e4eebe4ad675274266
Author:     Adam Seskunas <[email protected]>
AuthorDate: Mon Sep 16 13:57:40 2024 -0700
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Sep 27 10:19:31 2024 +0200

    Add file stats to check-missing-unittests.py
    
    Get files modified, insertions and deletions for
    each of the missing unit tests.
    
    Change-Id: I7b6c2f0f988137c533d7b9283faa9a2753ef41e9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173481
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/bin/check-missing-unittests.py b/bin/check-missing-unittests.py
index 0ee36ef76aaf..673e1f7b3308 100755
--- a/bin/check-missing-unittests.py
+++ b/bin/check-missing-unittests.py
@@ -34,6 +34,28 @@ def whiteboardNotes(whiteboard):
 
     return ''
 
+def linesModified(commit_hash):
+    repoPath = os.path.dirname(os.path.abspath(__file__)) + '/..'
+    commits = subprocess.check_output(
+            ['git', '-C', repoPath, 'show', commit_hash, '--shortstat'],
+            stderr=subprocess.DEVNULL)
+    linesmodified = commits.decode('utf-8', 'ignore').split('

')
+    stats = linesmodified[-1].strip("
").split(",")
+    insertions = 0
+    deletions = 0
+    # Make sure we have the file stats, a file stat must have
+    # file(s) changed in it
+    if "files changed" in linesmodified[-1] or "file changed" in 
linesmodified[-1]:
+        fileschanged = re.findall(r'\d+', stats[0])[0]
+        for element in stats:
+           if "+" in element:
+               insertions = re.findall(r'\d+', element)[0]
+           elif "-" in element:
+               deletions = re.findall(r'\d+', element)[0]
+        return [fileschanged, insertions, deletions]
+    else:
+        return ["not found", "not found", "not found"]
+
 def main(ignoredBugs):
     results = {
         'export': {
@@ -72,7 +94,7 @@ def main(ignoredBugs):
             ['git', '-C', repoPath, 'rev-parse', 'HEAD'],
             stderr=subprocess.DEVNULL)
     output = subprocess.check_output(
-            ['git', '-C', repoPath, 'log', '--since="2012-01-01', 
'--name-only' ,'--pretty=format:"%s%n%ad"', '--date=format:"%Y/%m/%d"'],
+            ['git', '-C', repoPath, 'log', '--since="2012-01-01', 
'--name-only' ,'--pretty=format:"%s%n%ad%n%H"', '--date=format:"%Y/%m/%d"'],
             stderr=subprocess.DEVNULL)
     commits = output.decode('utf-8', 'ignore').split('

')
 
@@ -100,10 +122,11 @@ def main(ignoredBugs):
             if bugId in hasTestSet:
                 continue
 
+            commitHash = commitInfo[2].strip('"')
             date = commitInfo[1].strip('"')
-            infoList = [date, summary]
+            infoList = [date, summary, commitHash]
 
-            changedFiles = "".join(commitInfo[2:])
+            changedFiles = "".join(commitInfo[3:])
             if 'qa' in changedFiles:
                 hasTestSet.add(bugId)
                 continue
@@ -199,6 +222,7 @@ def main(ignoredBugs):
                 # Ignore performance bugs and accessibility bugs
                 if resolution and resolution == 'FIXED' and 'perf' not in 
keywords \
                         and 'accessibility' not in keywords:
+                    stats = linesModified(info[2])
                     fixList.append({
                         "id": bugId,
                         "date": info[0],
@@ -206,6 +230,9 @@ def main(ignoredBugs):
                         "summary": info[1],
                         "maintopic":k,
                         "subtopic":k1,
+                        "fileschanged": stats[0],
+                        "insertions": stats[1],
+                        "deletions": stats[2],
                         "notes": notes
                     })
 

Reply via email to