# [PATCH 0/2] Make check-whitespace failures more helpful

18 messages from 2022-12-16 to 2022-12-21. Participants: Chris. Webster via GitGitGadget, Junio C Hamano, Chris Webster, Đoàn Trần Công Danh.
Thread: https://gitlist.dev/t/58965

## Chris. Webster via GitGitGadget, 2022-12-16 08:31

Subject: [PATCH 0/2] Make check-whitespace failures more helpful
Message-ID: <pull.1444.git.1671179520.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/pull.1444.git.1671179520.gitgitgadget%40gmail.com

```
Add the errors to the job summary along with suggested commands to fix the
problem. The commits and filenames are links.

This is for issue #1395. Sample job output
[https://github.com/webstech/check-whitespace/actions/runs/3707382446]:

❌ A whitespace issue was found in one or more of the commits.

Run these commands to correct the problem:

1. git rebase --whitespace=fix aaa04a9
2. git push --force

Errors:

1. --- 5cd37f6 Remove annotations
   trailing.txt:4: trailing whitespace.
   +
   trailing.txt:2: new blank line at EOF.


Chris. Webster (2):
  Make `check-whitespace` failures more helpful
  Improve check-whitespace output

 .github/workflows/check-whitespace.yml | 57 +++++++++++++++++++++-----
 1 file changed, 46 insertions(+), 11 deletions(-)


base-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1444%2Fwebstech%2Fwhitespace-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1444/webstech/whitespace-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1444
-- 
gitgitgadget

```

## Chris. Webster via GitGitGadget, 2022-12-16 08:32

Subject: [PATCH 2/2] Improve check-whitespace output
Message-ID: <cdc2b1aae81f8c37b4e71cb3e0e382cf82de2272.1671179520.git.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/cdc2b1aae81f8c37b4e71cb3e0e382cf82de2272.1671179520.git.gitgitgadget%40gmail.com
In-Reply-To: <pull.1444.git.1671179520.gitgitgadget@gmail.com>

```
From: "Chris. Webster" <chris@webstech.net>

A message in the step log will refer to the Summary output.

The job summary output now has links to the commits and files.

Signed-off-by: Chris. Webster <chris@webstech.net>
---
 .github/workflows/check-whitespace.yml | 34 +++++++++++++++++++-------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml
index 3a99073bc33..da557fd5914 100644
--- a/.github/workflows/check-whitespace.yml
+++ b/.github/workflows/check-whitespace.yml
@@ -20,46 +20,62 @@ jobs:
     - name: git log --check
       id: check_out
       run: |
+        baseSha=${{github.event.pull_request.base.sha}}
         problems=()
         commit=
         commitText=
-        lastcommit=
+        commitTextmd=
+        goodparent=
         while read dash sha etc
         do
           case "${dash}" in
           "---")
             if test -z "${commit}"
             then
-              lastcommit=${sha}
+              goodparent=${sha}
             fi
             commit="${sha}"
             commitText="${sha} ${etc}"
+            commitTextmd="[${sha}](https://github.com/${{ github.repository }}/commit/${sha}) ${etc}"
             ;;
           "")
             ;;
           *)
             if test -n "${commit}"
             then
-              problems+=("" "--- ${commitText}")
+              problems+=("1) --- ${commitTextmd}")
               echo ""
               echo "--- ${commitText}"
               commit=
             fi
-            problems+=("${dash} ${sha} ${etc}")
-            echo "${problems[-1]}"
+            case "${dash}" in
+            *:[1-9]*:) # contains file and line number information
+              dashend=${dash#*:}
+              problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
+              ;;
+            *)
+              problems+=("\`${dash} ${sha} ${etc}\`")
+              ;;
+            esac
+            echo "${dash} ${sha} ${etc}"
             ;;
           esac
-        done <<< $(git log --check --pretty=format:"---% h% s" ${{github.event.pull_request.base.sha}}..)
+        done <<< $(git log --check --pretty=format:"---% h% s" ${baseSha}..)
 
         if test ${#problems[*]} -gt 0
         then
           if test -z "${commit}"
           then
-            lastcommit=${{github.event.pull_request.base.sha}}
+            goodparent=${baseSha: 0:7}
           fi
-          echo "A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY
+          echo "🛑 Please review the Summary output for further information."
+          echo "### :x: 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
+          echo "Run these commands to correct the problem:" >>$GITHUB_STEP_SUMMARY
+          echo "1. \`git rebase --whitespace=fix ${goodparent}\`" >>$GITHUB_STEP_SUMMARY
+          echo "1. \`git push --force\`" >>$GITHUB_STEP_SUMMARY
+          echo " " >>$GITHUB_STEP_SUMMARY
+          echo "Errors:" >>$GITHUB_STEP_SUMMARY
           for i in "${problems[@]}"
           do
             echo "${i}" >>$GITHUB_STEP_SUMMARY
-- 
gitgitgadget

```

## Chris. Webster via GitGitGadget, 2022-12-16 08:31

Subject: [PATCH 1/2] Make `check-whitespace` failures more helpful
Message-ID: <67f60e4e5cbb470bbf3f556f962403af5dd5938c.1671179520.git.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/67f60e4e5cbb470bbf3f556f962403af5dd5938c.1671179520.git.gitgitgadget%40gmail.com
In-Reply-To: <pull.1444.git.1671179520.gitgitgadget@gmail.com>

```
From: "Chris. Webster" <chris@webstech.net>

Add the errors to the job summary along with suggested
commands to fix the problem.

Signed-off-by: Chris. Webster <chris@webstech.net>
---
 .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


```

## Junio C Hamano, 2022-12-16 10:06

Subject: Re: [PATCH 1/2] Make `check-whitespace` failures more helpful
Message-ID: <xmqqo7s3mzlt.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqo7s3mzlt.fsf%40gitster.g
In-Reply-To: <67f60e4e5cbb470bbf3f556f962403af5dd5938c.1671179520.git.gitgitgadget@gmail.com>

```
"Chris. Webster via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Subject: Re: [PATCH 1/2] Make `check-whitespace` failures more helpful

People usually make changes to the system to make it "more useful"
and/or "more helpful", and almost never to make it "less helpful".
Phrases you would use to explain why the failures become more
helpful with this change (compared to without) would help to promote
it in the "git shortlog --no-merges" output for the next release.
E.g. "make X failures stand out more", "make X failures gramatically
correct", "show X failures more concisely", etc.

> 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

I think we saw changes to upgrade actions/checkout@ in another
topic, and it seems that we have missed this one even though we
should have upgraded it the same way as other files in the same
directory?  Shouldn't this hunk be a separate topic on its own,
or at least a separate patch on its own in the series?

>        with:
>          fetch-depth: 0
>  
>      - name: git log --check
>        id: check_out
>        run: |
> -        log=
> +        problems=()

Is it safe to assume we run Bash here, or can GitHub start using
other shells that lack the Bash-ism shell arrays and we should
protect against such future?

I suspect that we are already depend on <<< Bash-ism, so one more
dependency to Bash-ism is not a problem here?  I dunno.

Thanks.

```

## Junio C Hamano, 2022-12-16 10:13

Subject: Re: [PATCH 2/2] Improve check-whitespace output
Message-ID: <xmqqh6xvmzb8.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqh6xvmzb8.fsf%40gitster.g
In-Reply-To: <cdc2b1aae81f8c37b4e71cb3e0e382cf82de2272.1671179520.git.gitgitgadget@gmail.com>

```
"Chris. Webster via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: "Chris. Webster" <chris@webstech.net>

> Subject: Re: [PATCH 2/2] Improve check-whitespace output

The same comment about specificity of the improvements applies to
this one, too.  Also, I forgot to point out that our usual commit
title takes the form of "<area>: <description>", e.g.

	Subject: [PATCH 2/2] ci: show $X in check.whitespace output

where "show $X" is meant to be a more concrete phrase than "improve"
what the change is about and how it improves the output.

> +          echo "Run these commands to correct the problem:" >>$GITHUB_STEP_SUMMARY
> +          echo "1. \`git rebase --whitespace=fix ${goodparent}\`" >>$GITHUB_STEP_SUMMARY
> +          echo "1. \`git push --force\`" >>$GITHUB_STEP_SUMMARY

It's a bit curious to see two "1." and not "1." followed by "2."
here.  Is this meant to be processed by markdown or something so we
do not have to do the numbering ourselves, or something?

> +          echo " " >>$GITHUB_STEP_SUMMARY
> +          echo "Errors:" >>$GITHUB_STEP_SUMMARY
>            for i in "${problems[@]}"
>            do
>              echo "${i}" >>$GITHUB_STEP_SUMMARY

Thanks.

```

## Chris Webster, 2022-12-20 00:30

Subject: Re: [PATCH 1/2] Make `check-whitespace` failures more helpful
Message-ID: <CAGT1KpXDHc2bqiiPqxwBiW2UV8BKMnbKD68hKa3fHdCA5GDAzw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGT1KpXDHc2bqiiPqxwBiW2UV8BKMnbKD68hKa3fHdCA5GDAzw%40mail.gmail.com
In-Reply-To: <xmqqo7s3mzlt.fsf@gitster.g>

```
On Fri, Dec 16, 2022 at 2:06 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> People usually make changes to the system to make it "more useful"
> and/or "more helpful", and almost never to make it "less helpful".
> Phrases you would use to explain why the failures become more
> helpful with this change (compared to without) would help to promote
> it in the "git shortlog --no-merges" output for the next release.
> E.g. "make X failures stand out more", "make X failures gramatically
> correct", "show X failures more concisely", etc.

I will resend with a hopefully better explanation.

> directory?  Shouldn't this hunk be a separate topic on its own,
> or at least a separate patch on its own in the series?

It will now be a separate patch.

> Is it safe to assume we run Bash here, or can GitHub start using
> other shells that lack the Bash-ism shell arrays and we should
> protect against such future?
>
> I suspect that we are already depend on <<< Bash-ism, so one more
> dependency to Bash-ism is not a problem here?  I dunno.

While GitHub could probably allow other shells to be used, changing
the default would probably break a lot of things at this point.

Thanks for the feedback,
...chris.

```

## Chris Webster, 2022-12-20 00:33

Subject: Re: [PATCH 2/2] Improve check-whitespace output
Message-ID: <CAGT1KpXET2kkwKCEpi5Ay=xHsEWLgXzFj9G0cTBFNYvCgAaUfQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAGT1KpXET2kkwKCEpi5Ay%3DxHsEWLgXzFj9G0cTBFNYvCgAaUfQ%40mail.gmail.com
In-Reply-To: <xmqqh6xvmzb8.fsf@gitster.g>

```
On Fri, Dec 16, 2022 at 2:13 AM Junio C Hamano <gitster@pobox.com> wrote:
> It's a bit curious to see two "1." and not "1." followed by "2."
> here.  Is this meant to be processed by markdown or something so we
> do not have to do the numbering ourselves, or something?

Yes, GITHUB_STEP_SUMMARY is treated as markdown.

Thanks for the feedback,
...chris.

```

## Chris. Webster via GitGitGadget, 2022-12-20 00:35

Subject: [PATCH v2 0/3] Make check-whitespace failures more helpful
Message-ID: <pull.1444.v2.git.1671496548.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/pull.1444.v2.git.1671496548.gitgitgadget%40gmail.com
In-Reply-To: <pull.1444.git.1671179520.gitgitgadget@gmail.com>

```
Add the errors to the job summary along with suggested commands to fix the
problem. The commits and filenames are links.

This is for issue #1395. Sample job output
[https://github.com/webstech/check-whitespace/actions/runs/3707382446]:

❌ A whitespace issue was found in one or more of the commits.

Run these commands to correct the problem:

1. git rebase --whitespace=fix aaa04a9
2. git push --force

Errors:

1. --- 5cd37f6 Remove annotations
   trailing.txt:4: trailing whitespace.
   +
   trailing.txt:2: new blank line at EOF.


Chris. Webster (3):
  ci (check-whitespace): suggest fixes for errors
  ci (check-whitespace): add links to job output
  ci (check-whitespace): move to actions/checkout@v3

 .github/workflows/check-whitespace.yml | 57 +++++++++++++++++++++-----
 1 file changed, 46 insertions(+), 11 deletions(-)


base-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1444%2Fwebstech%2Fwhitespace-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1444/webstech/whitespace-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1444

Range-diff vs v1:

 1:  67f60e4e5cb ! 1:  a2b5f3e87d6 Make `check-whitespace` failures more helpful
     @@ Metadata
      Author: Chris. Webster <chris@webstech.net>
      
       ## Commit message ##
     -    Make `check-whitespace` failures more helpful
     +    ci (check-whitespace): suggest fixes for errors
      
     -    Add the errors to the job summary along with suggested
     -    commands to fix the problem.
     +    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>
      
       ## .github/workflows/check-whitespace.yml ##
      @@ .github/workflows/check-whitespace.yml: 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: |
 2:  cdc2b1aae81 ! 2:  342167ef5bd Improve check-whitespace output
     @@ Metadata
      Author: Chris. Webster <chris@webstech.net>
      
       ## Commit message ##
     -    Improve check-whitespace output
     +    ci (check-whitespace): add links to job output
      
          A message in the step log will refer to the Summary output.
      
     -    The job summary output now has links to the commits and files.
     +    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 <chris@webstech.net>
      
 -:  ----------- > 3:  aa8cd940940 ci (check-whitespace): move to actions/checkout@v3

-- 
gitgitgadget

```

## Chris. Webster via GitGitGadget, 2022-12-20 00:35

Subject: [PATCH v2 1/3] ci (check-whitespace): suggest fixes for errors
Message-ID: <a2b5f3e87d6ef62d8005cff5568ad3afc4af3771.1671496548.git.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/a2b5f3e87d6ef62d8005cff5568ad3afc4af3771.1671496548.git.gitgitgadget%40gmail.com
In-Reply-To: <pull.1444.v2.git.1671496548.gitgitgadget@gmail.com>

```
From: "Chris. Webster" <chris@webstech.net>

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>
---
 .github/workflows/check-whitespace.yml | 37 +++++++++++++++++++-------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml
index ad3466ad16e..a0871489b24 100644
--- a/.github/workflows/check-whitespace.yml
+++ b/.github/workflows/check-whitespace.yml
@@ -20,31 +20,50 @@ jobs:
     - 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


```

## Chris. Webster via GitGitGadget, 2022-12-20 00:35

Subject: [PATCH v2 2/3] ci (check-whitespace): add links to job output
Message-ID: <342167ef5bd7f98a7248feea86f4f77b268988bb.1671496548.git.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/342167ef5bd7f98a7248feea86f4f77b268988bb.1671496548.git.gitgitgadget%40gmail.com
In-Reply-To: <pull.1444.v2.git.1671496548.gitgitgadget@gmail.com>

```
From: "Chris. Webster" <chris@webstech.net>

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 <chris@webstech.net>
---
 .github/workflows/check-whitespace.yml | 34 +++++++++++++++++++-------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml
index a0871489b24..552894f736a 100644
--- a/.github/workflows/check-whitespace.yml
+++ b/.github/workflows/check-whitespace.yml
@@ -20,46 +20,62 @@ jobs:
     - name: git log --check
       id: check_out
       run: |
+        baseSha=${{github.event.pull_request.base.sha}}
         problems=()
         commit=
         commitText=
-        lastcommit=
+        commitTextmd=
+        goodparent=
         while read dash sha etc
         do
           case "${dash}" in
           "---")
             if test -z "${commit}"
             then
-              lastcommit=${sha}
+              goodparent=${sha}
             fi
             commit="${sha}"
             commitText="${sha} ${etc}"
+            commitTextmd="[${sha}](https://github.com/${{ github.repository }}/commit/${sha}) ${etc}"
             ;;
           "")
             ;;
           *)
             if test -n "${commit}"
             then
-              problems+=("" "--- ${commitText}")
+              problems+=("1) --- ${commitTextmd}")
               echo ""
               echo "--- ${commitText}"
               commit=
             fi
-            problems+=("${dash} ${sha} ${etc}")
-            echo "${problems[-1]}"
+            case "${dash}" in
+            *:[1-9]*:) # contains file and line number information
+              dashend=${dash#*:}
+              problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
+              ;;
+            *)
+              problems+=("\`${dash} ${sha} ${etc}\`")
+              ;;
+            esac
+            echo "${dash} ${sha} ${etc}"
             ;;
           esac
-        done <<< $(git log --check --pretty=format:"---% h% s" ${{github.event.pull_request.base.sha}}..)
+        done <<< $(git log --check --pretty=format:"---% h% s" ${baseSha}..)
 
         if test ${#problems[*]} -gt 0
         then
           if test -z "${commit}"
           then
-            lastcommit=${{github.event.pull_request.base.sha}}
+            goodparent=${baseSha: 0:7}
           fi
-          echo "A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY
+          echo "🛑 Please review the Summary output for further information."
+          echo "### :x: 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
+          echo "Run these commands to correct the problem:" >>$GITHUB_STEP_SUMMARY
+          echo "1. \`git rebase --whitespace=fix ${goodparent}\`" >>$GITHUB_STEP_SUMMARY
+          echo "1. \`git push --force\`" >>$GITHUB_STEP_SUMMARY
+          echo " " >>$GITHUB_STEP_SUMMARY
+          echo "Errors:" >>$GITHUB_STEP_SUMMARY
           for i in "${problems[@]}"
           do
             echo "${i}" >>$GITHUB_STEP_SUMMARY
-- 
gitgitgadget


```

## Chris. Webster via GitGitGadget, 2022-12-20 00:35

Subject: [PATCH v2 3/3] ci (check-whitespace): move to actions/checkout@v3
Message-ID: <aa8cd9409401a6407eb6f92bd161ba0562ff3fc8.1671496548.git.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/aa8cd9409401a6407eb6f92bd161ba0562ff3fc8.1671496548.git.gitgitgadget%40gmail.com
In-Reply-To: <pull.1444.v2.git.1671496548.gitgitgadget@gmail.com>

```
From: "Chris. Webster" <chris@webstech.net>

Get rid of deprecation warnings in the CI runs.  Also gets the latest
security patches.

Signed-off-by: Chris. Webster <chris@webstech.net>
---
 .github/workflows/check-whitespace.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml
index 552894f736a..da557fd5914 100644
--- a/.github/workflows/check-whitespace.yml
+++ b/.github/workflows/check-whitespace.yml
@@ -13,7 +13,7 @@ jobs:
   check-whitespace:
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
       with:
         fetch-depth: 0
 
-- 
gitgitgadget

```

## Junio C Hamano, 2022-12-20 01:36

Subject: Re: [PATCH 1/2] Make `check-whitespace` failures more helpful
Message-ID: <xmqq5ye6zwin.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq5ye6zwin.fsf%40gitster.g
In-Reply-To: <CAGT1KpXDHc2bqiiPqxwBiW2UV8BKMnbKD68hKa3fHdCA5GDAzw@mail.gmail.com>

```
Chris Webster <chris@webstech.net> writes:

>> I suspect that we are already depend on <<< Bash-ism, so one more
>> dependency to Bash-ism is not a problem here?  I dunno.
>
> While GitHub could probably allow other shells to be used, changing
> the default would probably break a lot of things at this point.

Do we specifically ask for bash in our .github/ files?  That would
be perfectly acceptable.  Then we only have to worry about their
withdrawing support for bash which would never happen ;-)

Thanks.

```

## Chris Webster, 2022-12-20 05:50

Subject: Re: [PATCH 1/2] Make `check-whitespace` failures more helpful
Message-ID: <CAGT1KpWgu6j-Rb3ezmO+Uwj_LgsgXDbyogkHV=y1099SAk3=Zg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGT1KpWgu6j-Rb3ezmO%2BUwj_LgsgXDbyogkHV%3Dy1099SAk3%3DZg%40mail.gmail.com
In-Reply-To: <xmqq5ye6zwin.fsf@gitster.g>

```
On Mon, Dec 19, 2022 at 5:36 PM Junio C Hamano <gitster@pobox.com> wrote:
> Do we specifically ask for bash in our .github/ files?  That would
> be perfectly acceptable.  Then we only have to worry about their
> withdrawing support for bash which would never happen ;-)

We use the default but the default can be changed
https://docs.github.com/en/actions/using-jobs/setting-default-values-for-jobs.
IOW we can always use bash if the default changes.

...chris.

```

## Đoàn Trần Công Danh, 2022-12-20 07:34

Subject: Re: [PATCH v2 1/3] ci (check-whitespace): suggest fixes for errors
Message-ID: <Y6Fle8gzVU5si3T/@danh.dev>
URL: https://gitlist.dev/e/Y6Fle8gzVU5si3T%2F%40danh.dev
In-Reply-To: <a2b5f3e87d6ef62d8005cff5568ad3afc4af3771.1671496548.git.gitgitgadget@gmail.com>

```
On 2022-12-20 00:35:45+0000, "Chris. Webster via GitGitGadget" <gitgitgadget@gmail.com> wrote:
> From: "Chris. Webster" <chris@webstech.net>
> 
> 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>
> ---

I think this change is getting too long to be embeded in a yaml file.
I think it's better to move the shell code into its own script, so we
can have better code highlight in editor and a proper shebang (/bin/bash).

>  .github/workflows/check-whitespace.yml | 37 +++++++++++++++++++-------
>  1 file changed, 28 insertions(+), 9 deletions(-)
> 
> diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml
> index ad3466ad16e..a0871489b24 100644
> --- a/.github/workflows/check-whitespace.yml
> +++ b/.github/workflows/check-whitespace.yml
> @@ -20,31 +20,50 @@ jobs:
>      - 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

When move this block into its own script, we can use single quote
string here, too.

> +          for i in "${problems[@]}"
> +          do
> +            echo "${i}" >>$GITHUB_STEP_SUMMARY
> +          done
> +
>            exit 2
>          fi
> -- 
> gitgitgadget
> 

-- 
Danh

```

## Chris Webster, 2022-12-20 19:55

Subject: Re: [PATCH v2 1/3] ci (check-whitespace): suggest fixes for errors
Message-ID: <CAGT1KpV0igMKk4FvapuZCdJ7kFS+_cNe2ouczQsomheOGhgLZg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGT1KpV0igMKk4FvapuZCdJ7kFS%2B_cNe2ouczQsomheOGhgLZg%40mail.gmail.com
In-Reply-To: <Y6Fle8gzVU5si3T/@danh.dev>

```
> I think this change is getting too long to be embeded in a yaml file.
> I think it's better to move the shell code into its own script, so we
> can have better code highlight in editor and a proper shebang (/bin/bash).

That would need to be a separate patch?

> > +          echo "Run \`git rebase --whitespace=fix ${lastcommit}\` and \`git push --force\` to correct the problem." >>$GITHUB_STEP_SUMMARY
>
> When move this block into its own script, we can use single quote
> string here, too.

I am not sure what you mean.

Thanks for the review,
...chris.

```

## Đoàn Trần Công Danh, 2022-12-21 01:53

Subject: Re: [PATCH v2 1/3] ci (check-whitespace): suggest fixes for errors
Message-ID: <Y6JnEQY2VWU8gSZX@danh.dev>
URL: https://gitlist.dev/e/Y6JnEQY2VWU8gSZX%40danh.dev
In-Reply-To: <CAGT1KpV0igMKk4FvapuZCdJ7kFS+_cNe2ouczQsomheOGhgLZg@mail.gmail.com>

```
On 2022-12-20 11:55:57-0800, Chris Webster <chris@webstech.net> wrote:
> > I think this change is getting too long to be embeded in a yaml file.
> > I think it's better to move the shell code into its own script, so we
> > can have better code highlight in editor and a proper shebang (/bin/bash).
> 
> That would need to be a separate patch?

Yes, I think, a patch to move the whole block into a script, maybe in
ci/ folder.
> 
> > > +          echo "Run \`git rebase --whitespace=fix ${lastcommit}\` and \`git push --force\` to correct the problem." >>$GITHUB_STEP_SUMMARY
> >
> > When move this block into its own script, we can use single quote
> > string here, too.
> 
> I am not sure what you mean.

I mean we can write:

	echo 'Run `git rebase ...` to correct the problem'

With single quote, we need less escape.


-- 
Danh

```

## Chris Webster, 2022-12-21 06:08

Subject: Re: [PATCH v2 1/3] ci (check-whitespace): suggest fixes for errors
Message-ID: <CAGT1KpWBVcmxCJf=j7ks7azrX=oj3zLqbrThOjjPLqKu+8rBAg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGT1KpWBVcmxCJf%3Dj7ks7azrX%3Doj3zLqbrThOjjPLqKu%2B8rBAg%40mail.gmail.com
In-Reply-To: <Y6JnEQY2VWU8gSZX@danh.dev>

```
On Tue, Dec 20, 2022 at 5:53 PM Đoàn Trần Công Danh
<congdanhqx@gmail.com> wrote:
> Yes, I think, a patch to move the whole block into a script, maybe in
> ci/ folder.

Maybe before the next patch or someone could create a check-whitespace
workflow action.  Can this patch move forward?  A script would involve
validating parameters or env variables that are just workflow context
expressions now (ie more complexity).

> > I am not sure what you mean.
>
> I mean we can write:
>
>         echo 'Run `git rebase ...` to correct the problem'
>
> With single quote, we need less escape.

What about ${lastcommit}?  Yes, there is more than one way to do it.

thanks,
...chris.

```

## Đoàn Trần Công Danh, 2022-12-21 13:46

Subject: Re: [PATCH v2 1/3] ci (check-whitespace): suggest fixes for errors
Message-ID: <Y6MOLVoo/NtJy1C9@danh.dev>
URL: https://gitlist.dev/e/Y6MOLVoo%2FNtJy1C9%40danh.dev
In-Reply-To: <CAGT1KpWBVcmxCJf=j7ks7azrX=oj3zLqbrThOjjPLqKu+8rBAg@mail.gmail.com>

```
On 2022-12-20 22:08:58-0800, Chris Webster <chris@webstech.net> wrote:
> On Tue, Dec 20, 2022 at 5:53 PM Đoàn Trần Công Danh
> <congdanhqx@gmail.com> wrote:
> > Yes, I think, a patch to move the whole block into a script, maybe in
> > ci/ folder.
> 
> Maybe before the next patch or someone could create a check-whitespace
> workflow action.  Can this patch move forward?  A script would involve
> validating parameters or env variables that are just workflow context
> expressions now (ie more complexity).

I would say, we can just check an environment variables specific to
GitHub Action, and print a warning if it's missing. Other than that,
just process as normal.

> > > I am not sure what you mean.
> >
> > I mean we can write:
> >
> >         echo 'Run `git rebase ...` to correct the problem'
> >
> > With single quote, we need less escape.
> 
> What about ${lastcommit}?  Yes, there is more than one way to do it.

Ah, I misread that part. Sorry.

-- 
Danh

```
