Skip to content

ci: make the whitespace checker more robust #778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

dscho
Copy link
Member

@dscho dscho commented Nov 3, 2020

I noticed that the checker failed to add a comment in one of my PRs. Turns out that the double-quote characters in the log output made it fail.

One thing we discussed earlier whether the log should be pasted as pre-formatted text or not, and we fell on the side of not pre-formatting it. However, in my tests, this does not look right, and it looks much better pre-formatted (even if we unfortunately lose the direct link to the commit).

Cc: Chris. Webster chris@webstech.net

In 32c83af (ci: github action - add check for whitespace errors,
2020-09-22), we introduced a GitHub workflow that automatically checks
Pull Requests for whitespace problems.

However, when affected lines contain one or more double quote
characters, this workflow failed to attach the informative comment
because the Javascript snippet incorrectly interpreted these quotes
instead of using the `git log` output as-is.

Let's fix that.

While at it, let's `await` the result of the `createComment()` function.

Finally, we enclose the log in the comment with ```...``` to avoid
having the diff marker be misinterpreted as an enumeration bullet.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member Author

dscho commented Nov 3, 2020

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 3, 2020

Submitted as pull.778.git.1604418931303.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git pr-778/dscho/fix-whitespace-github-workflow-v1

To fetch this version to local tag pr-778/dscho/fix-whitespace-github-workflow-v1:

git fetch --no-tags https://github.com/gitgitgadget/git tag pr-778/dscho/fix-whitespace-github-workflow-v1

@webstech
Copy link

webstech commented Nov 3, 2020

Thanks for correcting this. Interesting when escaping is done/not done.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 3, 2020

On the Git mailing list, Junio C Hamano wrote (reply to this):

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

>     One thing we discussed earlier whether the log should be pasted as
>     pre-formatted text or not, and we fell on the side of not pre-formatting
>     it. However, in my tests, this does not look right
>     [https://github.com/dscho/git/pull/18#issuecomment-721160985], and it 
>     looks much better pre-formatted
>     [https://github.com/dscho/git/pull/18#issuecomment-721167209] (even if
>     we unfortunately lose the direct link to the commit
>     [https://github.com/dscho/git/commit/68317764849af81b17c4b31906da20bdf2c52082]
>     ).

What is shown in the log are lines from the source files that were
checked, and we expect our source files are shown and edited in
monospace with tabwidth=8, I think it does make sense to force the
"pre-formatted" output.

Thanks.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 3, 2020

This branch is now known as cw/ci-ghwf-check-ws-errors.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 3, 2020

This patch series was integrated into seen via git@ba574db.

@gitgitgadget gitgitgadget bot added the seen label Nov 3, 2020
@dscho
Copy link
Member Author

dscho commented Nov 3, 2020

Thanks for correcting this. Interesting when escaping is done/not done.

Indeed.

In this instance, it is actually even more interesting to think of the time when things are interpolated. The ${{ ... }} constructs are interpreted when writing the script that is eventually executed, i.e. way before the script is actually run. The ${ ... } construct is interpolated while the script is run.

So by letting the ${{ ... }} interpolation happen in the env block, I avoid having node.js interpret the double quote characters, and by letting node.js interpolate ${ process.env.<something> }, I again avoid having node.js interpret the double quote characters because that interpolation is done inside the `...` quotes.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 5, 2020

This patch series was integrated into seen via git@dc6020c.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 5, 2020

This patch series was integrated into next via git@dc11218.

@gitgitgadget gitgitgadget bot added the next label Nov 5, 2020
@gitgitgadget
Copy link

gitgitgadget bot commented Nov 9, 2020

This patch series was integrated into seen via git@387a366.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 11, 2020

This patch series was integrated into seen via git@c040efa.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 11, 2020

This patch series was integrated into seen via git@15486b6.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 11, 2020

This patch series was integrated into next via git@15486b6.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 11, 2020

This patch series was integrated into master via git@15486b6.

@gitgitgadget gitgitgadget bot added the master label Nov 11, 2020
@gitgitgadget gitgitgadget bot closed this Nov 11, 2020
@gitgitgadget
Copy link

gitgitgadget bot commented Nov 11, 2020

Closed via 15486b6.

@dscho dscho deleted the fix-whitespace-github-workflow branch November 12, 2020 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants