From 57f03491be7838279999a537384e0c9987e052d7 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Wed, 26 Jan 2022 15:25:39 +0000 Subject: [PATCH] scripts/machine-summary: link patches to cgit Add links from the patch names to the patches in cgit for ease of inspection. Signed-off-by: Ross Burton Signed-off-by: Jon Mason --- scripts/machine-summary.py | 20 +++++++++++++++++--- scripts/report-details.html.jinja | 7 +++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/machine-summary.py b/scripts/machine-summary.py index c07c2d15..47d8ff34 100755 --- a/scripts/machine-summary.py +++ b/scripts/machine-summary.py @@ -49,6 +49,19 @@ def layer_path(layername: str, d) -> pathlib.Path: return layer_path.cache[layername] return None +def get_url_for_patch(layer: str, localpath: pathlib.Path, d) -> str: + relative = localpath.relative_to(layer_path(layer, d)) + + # TODO: use layerindexlib + # TODO: assumes default branch + if layer == "core": + return f"https://git.openembedded.org/openembedded-core/tree/meta/{relative}" + elif layer in ("meta-arm", "meta-arm-bsp", "arm-toolchain", "meta-atp", "meta-gem5"): + return f"https://git.yoctoproject.org/meta-arm/tree/{layer}/{relative}" + else: + print(f"WARNING: Don't know web URL for layer {layer}", file=sys.stderr) + return None + def extract_patch_info(src_uri, d): """ Parse the specified patch entry from a SRC_URI and return (base name, layer name, status) tuple @@ -56,9 +69,10 @@ def extract_patch_info(src_uri, d): import bb.fetch, bb.utils info = {} - localpath = bb.fetch.decodeurl(src_uri)[2] - info["name"] = os.path.basename(localpath) - info["layer"] = bb.utils.get_file_layer(localpath, d) + localpath = pathlib.Path(bb.fetch.decodeurl(src_uri)[2]) + info["name"] = localpath.name + info["layer"] = bb.utils.get_file_layer(str(localpath), d) + info["url"] = get_url_for_patch(info["layer"], localpath, d) status = "Unknown" with open(localpath, errors="ignore") as f: diff --git a/scripts/report-details.html.jinja b/scripts/report-details.html.jinja index 19ede510..a656c261 100644 --- a/scripts/report-details.html.jinja +++ b/scripts/report-details.html.jinja @@ -47,8 +47,11 @@ {% for pinfo in data.patches %} - - {{ pinfo.name }} + + {% if pinfo.url %}{% endif %} + {{ pinfo.name }} + {% if pinfo.url %}{% endif %} + {{ pinfo.layer }} {{ make_patch_tag(pinfo.status)}}