All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ross Burton <ross.burton@arm.com>
To: meta-arm@lists.yoctoproject.org
Subject: [PATCH 2/3] scripts/machine-summary: link patches to cgit
Date: Wed, 26 Jan 2022 19:12:52 +0000	[thread overview]
Message-ID: <20220126191253.1844130-2-ross.burton@arm.com> (raw)
In-Reply-To: <20220126191253.1844130-1-ross.burton@arm.com>

Add links from the patch names to the patches in cgit for ease of
inspection.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 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 @@
     <tbody>
       {% for pinfo in data.patches %}
       <tr>
-        <!-- TODO links to cgit -->
-        <td>{{ pinfo.name }}</td>
+        <td>
+          {% if pinfo.url %}<a href="{{pinfo.url}}">{% endif %}
+          {{ pinfo.name }}
+          {% if pinfo.url %}</a>{% endif %}
+        </td>
         <td>{{ pinfo.layer }}</td>
         <!-- TODO: tooltip with full status? -->
         <td class="has-text-centered">{{ make_patch_tag(pinfo.status)}}</td>
-- 
2.25.1



  reply	other threads:[~2022-01-26 19:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26 19:12 [PATCH 1/3] scripts/machine-summary: improve layer_path Ross Burton
2022-01-26 19:12 ` Ross Burton [this message]
2022-01-26 19:12 ` [PATCH 3/3] CI: enable memory-resident bitbake Ross Burton
2022-01-27 14:52 ` [PATCH 1/3] scripts/machine-summary: improve layer_path Jon Mason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220126191253.1844130-2-ross.burton@arm.com \
    --to=ross.burton@arm.com \
    --cc=meta-arm@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.