mirror of
https://github.com/git/git
synced 2024-10-03 23:29:36 +00:00
ci (check-whitespace): suggest fixes for errors
Make the errors more visible by adding them to the job summary and display the git commands that will usually fix the problem. Signed-off-by: Chris. Webster <chris@webstech.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
c48035d29b
commit
288e3c4e3b
37
.github/workflows/check-whitespace.yml
vendored
37
.github/workflows/check-whitespace.yml
vendored
|
@ -20,31 +20,50 @@ jobs:
|
||||||
- name: git log --check
|
- name: git log --check
|
||||||
id: check_out
|
id: check_out
|
||||||
run: |
|
run: |
|
||||||
log=
|
problems=()
|
||||||
commit=
|
commit=
|
||||||
while read dash etc
|
commitText=
|
||||||
|
lastcommit=
|
||||||
|
while read dash sha etc
|
||||||
do
|
do
|
||||||
case "${dash}" in
|
case "${dash}" in
|
||||||
"---")
|
"---")
|
||||||
commit="${etc}"
|
if test -z "${commit}"
|
||||||
|
then
|
||||||
|
lastcommit=${sha}
|
||||||
|
fi
|
||||||
|
commit="${sha}"
|
||||||
|
commitText="${sha} ${etc}"
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if test -n "${commit}"
|
if test -n "${commit}"
|
||||||
then
|
then
|
||||||
log="${log}\n${commit}"
|
problems+=("" "--- ${commitText}")
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- ${commit}"
|
echo "--- ${commitText}"
|
||||||
|
commit=
|
||||||
fi
|
fi
|
||||||
commit=
|
problems+=("${dash} ${sha} ${etc}")
|
||||||
log="${log}\n${dash} ${etc}"
|
echo "${problems[-1]}"
|
||||||
echo "${dash} ${etc}"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done <<< $(git log --check --pretty=format:"---% h% s" ${{github.event.pull_request.base.sha}}..)
|
done <<< $(git log --check --pretty=format:"---% h% s" ${{github.event.pull_request.base.sha}}..)
|
||||||
|
|
||||||
if test -n "${log}"
|
if test ${#problems[*]} -gt 0
|
||||||
then
|
then
|
||||||
|
if test -z "${commit}"
|
||||||
|
then
|
||||||
|
lastcommit=${{github.event.pull_request.base.sha}}
|
||||||
|
fi
|
||||||
|
echo "A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >>$GITHUB_STEP_SUMMARY
|
||||||
|
echo "Run \`git rebase --whitespace=fix ${lastcommit}\` and \`git push --force\` to correct the problem." >>$GITHUB_STEP_SUMMARY
|
||||||
|
for i in "${problems[@]}"
|
||||||
|
do
|
||||||
|
echo "${i}" >>$GITHUB_STEP_SUMMARY
|
||||||
|
done
|
||||||
|
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue