ci (check-whitespace): add links to job output

A message in the step log will refer to the Summary output. The job summary output is using markdown to improve readability. The git commands and commits with errors are now in ordered lists. Commits and files in error are links to the user's repository. Signed-off-by: Chris. Webster <chris@webstech.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Chris. Webster committed Dec 20, 2022 at 00:35 UTC b3ecdc780d38d2d6e64323b42a88e24b05334fc9
1 file changed +25 -9
.github/workflows/check-whitespace.yml
+25 -9
@@ -20,46 +20,62 @@ jobs:
20 - name: git log --check
21 id: check_out
22 run: |
23 + baseSha=${{github.event.pull_request.base.sha}}
24 problems=()
25 commit=
26 commitText=
26 - lastcommit=
27 + commitTextmd=
28 + goodparent=
29 while read dash sha etc
30 do
31 case "${dash}" in
32 "---")
33 if test -z "${commit}"
34 then
33 - lastcommit=${sha}
35 + goodparent=${sha}
36 fi
37 commit="${sha}"
38 commitText="${sha} ${etc}"
39 + commitTextmd="[${sha}](https://github.com/${{ github.repository }}/commit/${sha}) ${etc}"
40 ;;
41 "")
42 ;;
43 *)
44 if test -n "${commit}"
45 then
43 - problems+=("" "--- ${commitText}")
46 + problems+=("1) --- ${commitTextmd}")
47 echo ""
48 echo "--- ${commitText}"
49 commit=
50 fi
48 - problems+=("${dash} ${sha} ${etc}")
49 - echo "${problems[-1]}"
51 + case "${dash}" in
52 + *:[1-9]*:) # contains file and line number information
53 + dashend=${dash#*:}
54 + problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
55 + ;;
56 + *)
57 + problems+=("\`${dash} ${sha} ${etc}\`")
58 + ;;
59 + esac
60 + echo "${dash} ${sha} ${etc}"
61 ;;
62 esac
52 - done <<< $(git log --check --pretty=format:"---% h% s" ${{github.event.pull_request.base.sha}}..)
63 + done <<< $(git log --check --pretty=format:"---% h% s" ${baseSha}..)
64
65 if test ${#problems[*]} -gt 0
66 then
67 if test -z "${commit}"
68 then
58 - lastcommit=${{github.event.pull_request.base.sha}}
69 + goodparent=${baseSha: 0:7}
70 fi
60 - echo "A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY
71 + echo "🛑 Please review the Summary output for further information."
72 + echo "### :x: A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY
73 echo "" >>$GITHUB_STEP_SUMMARY
62 - echo "Run \`git rebase --whitespace=fix ${lastcommit}\` and \`git push --force\` to correct the problem." >>$GITHUB_STEP_SUMMARY
74 + echo "Run these commands to correct the problem:" >>$GITHUB_STEP_SUMMARY
75 + echo "1. \`git rebase --whitespace=fix ${goodparent}\`" >>$GITHUB_STEP_SUMMARY
76 + echo "1. \`git push --force\`" >>$GITHUB_STEP_SUMMARY
77 + echo " " >>$GITHUB_STEP_SUMMARY
78 + echo "Errors:" >>$GITHUB_STEP_SUMMARY
79 for i in "${problems[@]}"
80 do
81 echo "${i}" >>$GITHUB_STEP_SUMMARY