[PATCH b4 2/3] review: sashiko: fix URLs

"Matthieu Baerts (NGI0)" <[email protected]>
Newsgroups org.kernel.linux.tools
Message-ID <[email protected]>
The displayed URL is currently leading to a 404, e.g.

  https://sashiko.dev/patch/93

I don't know if this URL was working at some points, but it is no longer
now. This one works:

  https://sashiko.dev/#/patchset/93

And in case of a series, ?part=X can be used, e.g.

  https://sashiko.dev/#/patchset/93?part=2

Assisted-by: My-reading-glasses
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
 src/b4/review/checks.py         | 5 ++++-
 src/tests/test_review_checks.py | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/b4/review/checks.py b/src/b4/review/checks.py
index 2ff825f..942935e 100644
--- a/src/b4/review/checks.py
+++ b/src/b4/review/checks.py
@@ -462,7 +462,7 @@ def _run_builtin_sashiko(msg: EmailMessage, sashiko_url: str) -> List[Dict[str,
     reviews = data.get('reviews', [])
     patches = data.get('patches', [])
     base_url = sashiko_url.rstrip('/')
-    patchset_url = f'{base_url}/patch/{ps_id}' if ps_id else ''
+    patchset_url = f'{base_url}/#/patchset/{ps_id if ps_id else msgid}'
 
     # Build a map from patch message-id to sashiko patch id
     patch_id_by_msgid: Dict[str, int] = {}
@@ -526,8 +526,10 @@ def _run_builtin_sashiko(msg: EmailMessage, sashiko_url: str) -> List[Dict[str,
     if sashiko_patch_id is None:
         return []
 
+    i = 1
     for review in reviews:
         if review.get('patch_id') == sashiko_patch_id:
+            patchset_url += f'?part={i}'
             review_status = review.get('status', '')
             if review_status == 'Skipped':
                 result_msg = review.get('result', '') or 'Skipped'
@@ -570,6 +572,7 @@ def _run_builtin_sashiko(msg: EmailMessage, sashiko_url: str) -> List[Dict[str,
             if findings:
                 result['details'] = json.dumps(findings)
             return [result]
+        i += 1
 
     # No review found for this patch
     return [
diff --git a/src/tests/test_review_checks.py b/src/tests/test_review_checks.py
index 1469bf3..ad0f222 100644
--- a/src/tests/test_review_checks.py
+++ b/src/tests/test_review_checks.py
@@ -861,7 +861,7 @@ class TestRunBuiltinSashiko:
         assert '1 critical' in results[0]['summary']
         assert '1 high' in results[0]['summary']
         assert '1 low' in results[0]['summary']
-        assert results[0]['url'] == 'https://sashiko.dev/patch/93'
+        assert results[0]['url'] == 'https://sashiko.dev/#/patchset/93'
         # Details should be valid JSON
         details = json.loads(results[0]['details'])
         assert len(details) == 3  # 1 low + 1 critical + 1 high
@@ -992,7 +992,7 @@ class TestRunBuiltinSashiko:
         msg = _make_msg(msgid='[email protected]')
         results = checks._run_builtin_sashiko(msg, 'https://sashiko.dev/')
         # Trailing slash should not cause double slash
-        assert results[0]['url'] == 'https://sashiko.dev/patch/93'
+        assert results[0]['url'] == 'https://sashiko.dev/#/patchset/93?part=1'
 
 
 class TestSashikoAutoWire:

-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.