mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
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. (From OE-Core rev: 77c96e43090cbf485aec612cc2315b85e5635dda) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
116c044212
commit
62c80e3a79
|
@ -197,7 +197,7 @@ def histogram(results):
|
||||||
for k in bars:
|
for k in bars:
|
||||||
print("%-20s %s (%d)" % (k.capitalize() if k else "No status", bars[k], counts[k]))
|
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
|
# 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
|
# 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,
|
# 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-*.
|
# meta-*.
|
||||||
|
|
||||||
if (candidate / "conf" / "layer.conf").exists():
|
if (candidate / "conf" / "layer.conf").exists():
|
||||||
print(f"{candidate} is a layer")
|
return [candidate.absolute()]
|
||||||
scan = [candidate]
|
|
||||||
else:
|
else:
|
||||||
print(f"{candidate} is not a layer, checking for sub-layers")
|
return [d.absolute() for d in candidate.iterdir() if d.is_dir() and (d.name == "meta" or d.name.startswith("meta-"))]
|
||||||
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))}")
|
|
||||||
|
|
||||||
|
# TODO these don't actually handle dynamic-layers/
|
||||||
|
|
||||||
|
def gather_patches(layers):
|
||||||
patches = []
|
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()
|
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]
|
patches += [os.path.join(directory, f) for f in filenames]
|
||||||
return patches
|
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__":
|
if __name__ == "__main__":
|
||||||
import argparse, subprocess, os, pathlib
|
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.add_argument("directory", type=pathlib.Path, metavar="DIRECTORY", help="directory to scan (layer, or repository of layers)")
|
||||||
args = args.parse_args()
|
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)
|
results = patchreview(patches)
|
||||||
analyse(results, want_blame=args.blame, verbose=args.verbose)
|
analyse(results, want_blame=args.blame, verbose=args.verbose)
|
||||||
|
|
||||||
|
@ -242,8 +251,11 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
row = collections.Counter()
|
row = collections.Counter()
|
||||||
row["total"] = len(results)
|
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["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", "-s", "--pretty=format:%H"]).decode("utf-8").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():
|
for r in results.values():
|
||||||
if r.upstream_status in status_values:
|
if r.upstream_status in status_values:
|
||||||
row[r.upstream_status] += 1
|
row[r.upstream_status] += 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user