git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Justin Tobler <jltobler@gmail.com>
To: git@vger.kernel.org
Cc: Justin Tobler <jltobler@gmail.com>
Subject: [PATCH v2 2/5] github-ci: fix link to whitespace error
Date: Thu,  2 May 2024 14:38:36 -0500	[thread overview]
Message-ID: <20240502193840.105355-3-jltobler@gmail.com> (raw)
In-Reply-To: <20240502193840.105355-1-jltobler@gmail.com>

When the `check-whitespace` CI job detects whitespace errors, a
formatted summary of the issue is generated. This summary contains links
to the commits and blobs responsible for the whitespace errors. The
generated links for blobs do not work and result in a 404.

Instead of using the reference name in the link, use the commit ID
directly. This fixes the broken link and also helps enable future
generalization of the script for other CI providers by removing one of
the GitHub specific CI variables used.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
 .github/workflows/check-whitespace.yml | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml
index a241a63428..a3a6913ecc 100644
--- a/.github/workflows/check-whitespace.yml
+++ b/.github/workflows/check-whitespace.yml
@@ -31,14 +31,15 @@ jobs:
         commit=
         commitText=
         commitTextmd=
-        goodparent=
+        goodParent=
         while read dash sha etc
         do
           case "${dash}" in
-          "---")
-            if test -z "${commit}"
+          "---") # Line contains commit information.
+            if test -z "${goodParent}"
             then
-              goodparent=${sha}
+              # Assume the commit has no whitespace errors until detected otherwise.
+              goodParent=${sha}
             fi
             commit="${sha}"
             commitText="${sha} ${etc}"
@@ -46,18 +47,18 @@ jobs:
             ;;
           "")
             ;;
-          *)
-            if test -n "${commit}"
+          *) # Line contains whitespace error information for current commit.
+            if test -n "${goodParent}"
             then
               problems+=("1) --- ${commitTextmd}")
               echo ""
               echo "--- ${commitText}"
-              commit=
+              goodParent=
             fi
             case "${dash}" in
             *:[1-9]*:) # contains file and line number information
               dashend=${dash#*:}
-              problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
+              problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${commit}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
               ;;
             *)
               problems+=("\`${dash} ${sha} ${etc}\`")
@@ -70,15 +71,15 @@ jobs:
 
         if test ${#problems[*]} -gt 0
         then
-          if test -z "${commit}"
+          if test -z "${goodParent}"
           then
-            goodparent=${baseSha: 0:7}
+            goodParent=${baseSha: 0:7}
           fi
           echo "🛑 Please review the Summary output for further information."
           echo "### :x: A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY
           echo "" >>$GITHUB_STEP_SUMMARY
           echo "Run these commands to correct the problem:" >>$GITHUB_STEP_SUMMARY
-          echo "1. \`git rebase --whitespace=fix ${goodparent}\`" >>$GITHUB_STEP_SUMMARY
+          echo "1. \`git rebase --whitespace=fix ${goodParent}\`" >>$GITHUB_STEP_SUMMARY
           echo "1. \`git push --force\`" >>$GITHUB_STEP_SUMMARY
           echo " " >>$GITHUB_STEP_SUMMARY
           echo "Errors:" >>$GITHUB_STEP_SUMMARY
-- 
2.45.0


  parent reply	other threads:[~2024-05-02 19:41 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30  0:33 [PATCH 0/2] Add GitLab CI to check for whitespace errors Justin Tobler
2024-04-30  0:33 ` [PATCH 1/2] ci: pre-collapse GitLab CI sections Justin Tobler
2024-04-30  0:33 ` [PATCH 2/2] gitlab-ci: add whitespace error check Justin Tobler
2024-04-30  1:59   ` James Liu
2024-04-30  3:01     ` Justin Tobler
2024-04-30  5:04       ` Patrick Steinhardt
2024-04-30  5:04   ` Patrick Steinhardt
2024-04-30 12:14     ` Taylor Blau
2024-04-30 14:00     ` Justin Tobler
2024-04-30 14:05       ` Patrick Steinhardt
2024-04-30 14:41         ` Justin Tobler
2024-04-30 14:45           ` Patrick Steinhardt
2024-04-30 14:58             ` Justin Tobler
2024-05-02 19:38 ` [PATCH v2 0/5] Add GitLab CI to check for whitespace errors Justin Tobler
2024-05-02 19:38   ` [PATCH v2 1/5] ci: pre-collapse GitLab CI sections Justin Tobler
2024-05-02 19:38   ` Justin Tobler [this message]
2024-05-02 19:38   ` [PATCH v2 3/5] ci: separate whitespace check script Justin Tobler
2024-05-03  6:56     ` Patrick Steinhardt
2024-05-03 15:27       ` Justin Tobler
2024-05-03 16:49         ` Junio C Hamano
2024-05-03 17:59           ` Patrick Steinhardt
2024-05-04  6:51             ` Chris Torek
2024-05-02 19:38   ` [PATCH v2 4/5] ci: make the whitespace report optional Justin Tobler
2024-05-03  6:56     ` Patrick Steinhardt
2024-05-03 15:35       ` Justin Tobler
2024-05-02 19:38   ` [PATCH v2 5/5] gitlab-ci: add whitespace error check Justin Tobler
2024-05-03  6:56     ` Patrick Steinhardt
2024-05-02 21:45   ` [PATCH v2 0/5] Add GitLab CI to check for whitespace errors Junio C Hamano
2024-05-03 15:39     ` Justin Tobler
2024-05-03 17:21   ` [PATCH v3 " Justin Tobler
2024-05-03 17:21     ` [PATCH v3 1/5] ci: pre-collapse GitLab CI sections Justin Tobler
2024-05-03 17:21     ` [PATCH v3 2/5] github-ci: fix link to whitespace error Justin Tobler
2024-05-03 17:21     ` [PATCH v3 3/5] ci: separate whitespace check script Justin Tobler
2024-05-03 17:21     ` [PATCH v3 4/5] ci: make the whitespace report optional Justin Tobler
2024-05-03 17:21     ` [PATCH v3 5/5] gitlab-ci: add whitespace error check Justin Tobler
2024-05-06  6:55       ` Patrick Steinhardt
2024-05-06 13:59         ` Justin Tobler
2024-05-06 17:17         ` Junio C Hamano
2024-05-06 19:21           ` Justin Tobler
2024-05-07  4:12             ` Patrick Steinhardt
2024-05-07 18:06               ` Justin Tobler
2024-05-07 18:12                 ` Patrick Steinhardt

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=20240502193840.105355-3-jltobler@gmail.com \
    --to=jltobler@gmail.com \
    --cc=git@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).