Skip to content

Commit ecaacbc

Browse files
jltoblergitster
authored andcommitted
github-ci: fix link to whitespace error
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7789ea5 commit ecaacbc

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

.github/workflows/check-whitespace.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,34 @@ jobs:
3131
commit=
3232
commitText=
3333
commitTextmd=
34-
goodparent=
34+
goodParent=
3535
while read dash sha etc
3636
do
3737
case "${dash}" in
38-
"---")
39-
if test -z "${commit}"
38+
"---") # Line contains commit information.
39+
if test -z "${goodParent}"
4040
then
41-
goodparent=${sha}
41+
# Assume the commit has no whitespace errors until detected otherwise.
42+
goodParent=${sha}
4243
fi
4344
commit="${sha}"
4445
commitText="${sha} ${etc}"
4546
commitTextmd="[${sha}](https://github.com/${{ github.repository }}/commit/${sha}) ${etc}"
4647
;;
4748
"")
4849
;;
49-
*)
50-
if test -n "${commit}"
50+
*) # Line contains whitespace error information for current commit.
51+
if test -n "${goodParent}"
5152
then
5253
problems+=("1) --- ${commitTextmd}")
5354
echo ""
5455
echo "--- ${commitText}"
55-
commit=
56+
goodParent=
5657
fi
5758
case "${dash}" in
5859
*:[1-9]*:) # contains file and line number information
5960
dashend=${dash#*:}
60-
problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
61+
problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${commit}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
6162
;;
6263
*)
6364
problems+=("\`${dash} ${sha} ${etc}\`")
@@ -70,15 +71,15 @@ jobs:
7071
7172
if test ${#problems[*]} -gt 0
7273
then
73-
if test -z "${commit}"
74+
if test -z "${goodParent}"
7475
then
75-
goodparent=${baseSha: 0:7}
76+
goodParent=${baseSha: 0:7}
7677
fi
7778
echo "🛑 Please review the Summary output for further information."
7879
echo "### :x: A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY
7980
echo "" >>$GITHUB_STEP_SUMMARY
8081
echo "Run these commands to correct the problem:" >>$GITHUB_STEP_SUMMARY
81-
echo "1. \`git rebase --whitespace=fix ${goodparent}\`" >>$GITHUB_STEP_SUMMARY
82+
echo "1. \`git rebase --whitespace=fix ${goodParent}\`" >>$GITHUB_STEP_SUMMARY
8283
echo "1. \`git push --force\`" >>$GITHUB_STEP_SUMMARY
8384
echo " " >>$GITHUB_STEP_SUMMARY
8485
echo "Errors:" >>$GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)