summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2023-10-27 16:29:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-10-27 17:48:08 +0100
commit77c96e43090cbf485aec612cc2315b85e5635dda (patch)
tree0a4ee741bff0594239ceeb1d7e8f4713961c9c8b
parenta3a868519beab1b9cac94fefd7dbeffb09d047e9 (diff)
downloadopenembedded-core-contrib-77c96e43090cbf485aec612cc2315b85e5635dda.tar.gz
scripts/contrib/patchreview: add commit and recipe count fields to JSON
The autobuilder scripts post-process the generated JSON to inject recipe and commit counts into the data. We can do this easily in patchreview instead. Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/contrib/patchreview.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/scripts/contrib/patchreview.py b/scripts/contrib/patchreview.py
index af66e32e02..36038d06d2 100755
--- a/scripts/contrib/patchreview.py
+++ b/scripts/contrib/patchreview.py
@@ -197,7 +197,7 @@ def histogram(results):
for k in bars:
print("%-20s %s (%d)" % (k.capitalize() if k else "No status", bars[k], counts[k]))
-def gather_patches(candidate):
+def find_layers(candidate):
# candidate can either be the path to a layer directly (eg meta-intel), or a
# repository that contains other layers (meta-arm). We can determine what by
# looking for a conf/layer.conf file. If that file exists then it's a layer,
@@ -205,19 +205,26 @@ def gather_patches(candidate):
# meta-*.
if (candidate / "conf" / "layer.conf").exists():
- print(f"{candidate} is a layer")
- scan = [candidate]
+ return [candidate.absolute()]
else:
- print(f"{candidate} is not a layer, checking for sub-layers")
- scan = [d for d in candidate.iterdir() if d.is_dir() and (d.name == "meta" or d.name.startswith("meta-"))]
- print(f"Found layers {' '.join((d.name for d in scan))}")
+ return [d.absolute() for d in candidate.iterdir() if d.is_dir() and (d.name == "meta" or d.name.startswith("meta-"))]
+# TODO these don't actually handle dynamic-layers/
+
+def gather_patches(layers):
patches = []
- for directory in scan:
+ for directory in layers:
filenames = subprocess.check_output(("git", "-C", directory, "ls-files", "recipes-*/**/*.patch", "recipes-*/**/*.diff"), universal_newlines=True).split()
patches += [os.path.join(directory, f) for f in filenames]
return patches
+def count_recipes(layers):
+ count = 0
+ for directory in layers:
+ output = subprocess.check_output(["git", "-C", directory, "ls-files", "recipes-*/**/*.bb"], universal_newlines=True)
+ count += len(output.splitlines())
+ return count
+
if __name__ == "__main__":
import argparse, subprocess, os, pathlib
@@ -229,7 +236,9 @@ if __name__ == "__main__":
args.add_argument("directory", type=pathlib.Path, metavar="DIRECTORY", help="directory to scan (layer, or repository of layers)")
args = args.parse_args()
- patches = gather_patches(args.directory)
+ layers = find_layers(args.directory)
+ print(f"Found layers {' '.join((d.name for d in layers))}")
+ patches = gather_patches(layers)
results = patchreview(patches)
analyse(results, want_blame=args.blame, verbose=args.verbose)
@@ -242,8 +251,11 @@ if __name__ == "__main__":
row = collections.Counter()
row["total"] = len(results)
- row["date"] = subprocess.check_output(["git", "-C", args.directory, "show", "-s", "--pretty=format:%cd", "--date=format:%s"]).decode("utf-8").strip()
- row["commit"] = subprocess.check_output(["git", "-C", args.directory, "show", "-s", "--pretty=format:%H"]).decode("utf-8").strip()
+ row["date"] = subprocess.check_output(["git", "-C", args.directory, "show", "-s", "--pretty=format:%cd", "--date=format:%s"], universal_newlines=True).strip()
+ row["commit"] = subprocess.check_output(["git", "-C", args.directory, "show-ref", "--hash", "HEAD"], universal_newlines=True).strip()
+ row['commit_count'] = subprocess.check_output(["git", "-C", args.directory, "rev-list", "--count", "HEAD"], universal_newlines=True).strip()
+ row['recipe_count'] = count_recipes(layers)
+
for r in results.values():
if r.upstream_status in status_values:
row[r.upstream_status] += 1