From: "Chris. Webster" <chris@xxxxxxxxxxxx> Add the errors to the job summary along with suggested commands to fix the problem. Signed-off-by: Chris. Webster <chris@xxxxxxxxxxxx> --- .github/workflows/check-whitespace.yml | 39 +++++++++++++++++++------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml index ad3466ad16e..3a99073bc33 100644 --- a/.github/workflows/check-whitespace.yml +++ b/.github/workflows/check-whitespace.yml @@ -13,38 +13,57 @@ jobs: check-whitespace: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: git log --check id: check_out run: | - log= + problems=() commit= - while read dash etc + commitText= + lastcommit= + while read dash sha etc do case "${dash}" in "---") - commit="${etc}" + if test -z "${commit}" + then + lastcommit=${sha} + fi + commit="${sha}" + commitText="${sha} ${etc}" ;; "") ;; *) if test -n "${commit}" then - log="${log}\n${commit}" + problems+=("" "--- ${commitText}") echo "" - echo "--- ${commit}" + echo "--- ${commitText}" + commit= fi - commit= - log="${log}\n${dash} ${etc}" - echo "${dash} ${etc}" + problems+=("${dash} ${sha} ${etc}") + echo "${problems[-1]}" ;; esac done <<< $(git log --check --pretty=format:"---% h% s" ${{github.event.pull_request.base.sha}}..) - if test -n "${log}" + if test ${#problems[*]} -gt 0 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 fi -- gitgitgadget