Skip to content

Commit b3ecdc7

Browse files
webstechgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 288e3c4 commit b3ecdc7

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

.github/workflows/check-whitespace.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,62 @@ jobs:
2020
- name: git log --check
2121
id: check_out
2222
run: |
23+
baseSha=${{github.event.pull_request.base.sha}}
2324
problems=()
2425
commit=
2526
commitText=
26-
lastcommit=
27+
commitTextmd=
28+
goodparent=
2729
while read dash sha etc
2830
do
2931
case "${dash}" in
3032
"---")
3133
if test -z "${commit}"
3234
then
33-
lastcommit=${sha}
35+
goodparent=${sha}
3436
fi
3537
commit="${sha}"
3638
commitText="${sha} ${etc}"
39+
commitTextmd="[${sha}](https://github.com/${{ github.repository }}/commit/${sha}) ${etc}"
3740
;;
3841
"")
3942
;;
4043
*)
4144
if test -n "${commit}"
4245
then
43-
problems+=("" "--- ${commitText}")
46+
problems+=("1) --- ${commitTextmd}")
4447
echo ""
4548
echo "--- ${commitText}"
4649
commit=
4750
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}"
5061
;;
5162
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}..)
5364
5465
if test ${#problems[*]} -gt 0
5566
then
5667
if test -z "${commit}"
5768
then
58-
lastcommit=${{github.event.pull_request.base.sha}}
69+
goodparent=${baseSha: 0:7}
5970
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
6173
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
6379
for i in "${problems[@]}"
6480
do
6581
echo "${i}" >>$GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)