git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 2/5] github-ci: fix link to whitespace error

From
Justin Tobler <jltobler@gmail.com>
Date
May 3, 2024, 17:21 UTC
Message-ID
<20240503172110.181326-3-jltobler@gmail.com>
In-Reply-To
<20240503172110.181326-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
Previous: Justin ToblerNext: Justin Tobler
Message 32 of 42 in “Add GitLab CI to check for whitespace errors”
  1. 0/2 Add GitLab CI to check for whitespace errorsJustin Tobler, Apr 30, 2024
  2. 1/2 ci: pre-collapse GitLab CI sectionsJustin Tobler, Apr 30, 2024
  3. 2/2 gitlab-ci: add whitespace error checkJustin Tobler, Apr 30, 2024
  4. James LiuApr 30, 2024
  5. Justin ToblerApr 30, 2024
  6. Patrick SteinhardtApr 30, 2024
  7. Patrick SteinhardtApr 30, 2024
  8. Taylor BlauApr 30, 2024
  9. Justin ToblerApr 30, 2024
  10. Patrick SteinhardtApr 30, 2024
  11. Justin ToblerApr 30, 2024
  12. Patrick SteinhardtApr 30, 2024
  13. Justin ToblerApr 30, 2024
  14. 0/5 Add GitLab CI to check for whitespace errorsJustin Tobler, May 2, 2024
  15. 1/5 ci: pre-collapse GitLab CI sectionsJustin Tobler, May 2, 2024
  16. 2/5 github-ci: fix link to whitespace errorJustin Tobler, May 2, 2024
  17. 3/5 ci: separate whitespace check scriptJustin Tobler, May 2, 2024
  18. Patrick SteinhardtMay 3, 2024
  19. Justin ToblerMay 3, 2024
  20. Junio C HamanoMay 3, 2024
  21. Patrick SteinhardtMay 3, 2024
  22. Chris TorekMay 4, 2024
  23. 4/5 ci: make the whitespace report optionalJustin Tobler, May 2, 2024
  24. Patrick SteinhardtMay 3, 2024
  25. Justin ToblerMay 3, 2024
  26. 5/5 gitlab-ci: add whitespace error checkJustin Tobler, May 2, 2024
  27. Patrick SteinhardtMay 3, 2024
  28. Junio C HamanoMay 2, 2024
  29. Justin ToblerMay 3, 2024
  30. 0/5 Add GitLab CI to check for whitespace errorsJustin Tobler, May 3, 2024
  31. 1/5 ci: pre-collapse GitLab CI sectionsJustin Tobler, May 3, 2024
  32. 2/5 github-ci: fix link to whitespace errorJustin Tobler, May 3, 2024
  33. 3/5 ci: separate whitespace check scriptJustin Tobler, May 3, 2024
  34. 4/5 ci: make the whitespace report optionalJustin Tobler, May 3, 2024
  35. 5/5 gitlab-ci: add whitespace error checkJustin Tobler, May 3, 2024
  36. Patrick SteinhardtMay 6, 2024
  37. Justin ToblerMay 6, 2024
  38. Junio C HamanoMay 6, 2024
  39. Justin ToblerMay 6, 2024
  40. Patrick SteinhardtMay 7, 2024
  41. Justin ToblerMay 7, 2024
  42. Patrick SteinhardtMay 7, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.