{"thread":{"id":"54564","subject":"[PATCH] ci: make the whitespace checker more robust","startedAt":"2020-11-03T15:55:37Z","lastAt":"2020-11-03T22:02:57Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"409004","messageId":"pull.778.git.1604418931303.gitgitgadget@gmail.com","threadId":"54564","inReplyTo":null,"subject":"[PATCH] ci: make the whitespace checker more robust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-11-03T15:55:31Z","receivedAt":"2020-11-03T15:55:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nIn 32c83afc2c69 (ci: github action - add check for whitespace errors,\n2020-09-22), we introduced a GitHub workflow that automatically checks\nPull Requests for whitespace problems.\n\nHowever, when affected lines contain one or more double quote\ncharacters, this workflow failed to attach the informative comment\nbecause the Javascript snippet incorrectly interpreted these quotes\ninstead of using the `git log` output as-is.\n\nLet's fix that.\n\nWhile at it, let's `await` the result of the `createComment()` function.\n\nFinally, we enclose the log in the comment with ```...``` to avoid\nhaving the diff marker be misinterpreted as an enumeration bullet.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n    ci: make the whitespace checker more robust\n    \n    I noticed that the checker failed to add a comment\n    [https://github.com/gitgitgadget/git/runs/1344883313?check_suite_focus=true] \n    in one of my PRs. Turns out that the double-quote characters in the log\n    output made it fail.\n    \n    One thing we discussed earlier whether the log should be pasted as\n    pre-formatted text or not, and we fell on the side of not pre-formatting\n    it. However, in my tests, this does not look right\n    [https://github.com/dscho/git/pull/18#issuecomment-721160985], and it \n    looks much better pre-formatted\n    [https://github.com/dscho/git/pull/18#issuecomment-721167209] (even if\n    we unfortunately lose the direct link to the commit\n    [https://github.com/dscho/git/commit/68317764849af81b17c4b31906da20bdf2c52082]\n    ).\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-778%2Fdscho%2Ffix-whitespace-github-workflow-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-778/dscho/fix-whitespace-github-workflow-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/778\n\n .github/workflows/check-whitespace.yml | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml\nindex 9d070b9cdf..80a961716b 100644\n--- a/.github/workflows/check-whitespace.yml\n+++ b/.github/workflows/check-whitespace.yml\n@@ -58,12 +58,14 @@ jobs:\n     - name: Add Check Output as Comment\n       uses: actions/github-script@v3\n       id: add-comment\n+      env:\n+        log: ${{ steps.check_out.outputs.checkout }}\n       with:\n         script: |\n-            github.issues.createComment({\n+            await github.issues.createComment({\n               issue_number: context.issue.number,\n               owner: context.repo.owner,\n               repo: context.repo.repo,\n-              body: \"Whitespace errors found in workflow ${{ github.workflow }}:\\n\\n${{ steps.check_out.outputs.checkout }}\"\n+              body: `Whitespace errors found in workflow ${{ github.workflow }}:\\n\\n\\`\\`\\`\\n${process.env.log.replace(/\\\\n/g, \"\\n\")}\\n\\`\\`\\``\n             })\n       if: ${{ failure() }}\n\nbase-commit: 32c83afc2c69aa51b82aa223f2099389f1f0be0a\n-- \ngitgitgadget\n"},{"id":"409051","messageId":"xmqqsg9qp08x.fsf@gitster.c.googlers.com","threadId":"54564","inReplyTo":"pull.778.git.1604418931303.gitgitgadget@gmail.com","subject":"Re: [PATCH] ci: make the whitespace checker more robust","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-03T22:02:38Z","receivedAt":"2020-11-03T22:02:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n>     One thing we discussed earlier whether the log should be pasted as\n>     pre-formatted text or not, and we fell on the side of not pre-formatting\n>     it. However, in my tests, this does not look right\n>     [https://github.com/dscho/git/pull/18#issuecomment-721160985], and it \n>     looks much better pre-formatted\n>     [https://github.com/dscho/git/pull/18#issuecomment-721167209] (even if\n>     we unfortunately lose the direct link to the commit\n>     [https://github.com/dscho/git/commit/68317764849af81b17c4b31906da20bdf2c52082]\n>     ).\n\nWhat is shown in the log are lines from the source files that were\nchecked, and we expect our source files are shown and edited in\nmonospace with tabwidth=8, I think it does make sense to force the\n\"pre-formatted\" output.\n\nThanks.\n"}]}