3 # Get the repository with all commits to ensure that we can analyze
4 # all of the commits contributed via the Pull Request.
5 # Process `git log --check` output to extract just the check errors.
6 # Exit with failure upon white-space issues.
10 types: [opened, synchronize]
14 runs-on: ubuntu-latest
16 - uses: actions/checkout@v3
20 - name: git log --check
23 baseSha=${{github.event.pull_request.base.sha}}
29 while read dash sha etc
33 if test -z "${commit}"
38 commitText="${sha} ${etc}"
39 commitTextmd="[${sha}](https://github.com/${{ github.repository }}/commit/${sha}) ${etc}"
44 if test -n "${commit}"
46 problems+=("1) --- ${commitTextmd}")
48 echo "--- ${commitText}"
52 *:[1-9]*:) # contains file and line number information
54 problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
57 problems+=("\`${dash} ${sha} ${etc}\`")
60 echo "${dash} ${sha} ${etc}"
63 done <<< $(git log --check --pretty=format:"---% h% s" ${baseSha}..)
65 if test ${#problems[*]} -gt 0
67 if test -z "${commit}"
69 goodparent=${baseSha: 0:7}
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
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[@]}"
81 echo "${i}" >>$GITHUB_STEP_SUMMARY