Skip to content
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

Use double quotes to preserve adjacent spaces correctly #95

Merged
merged 1 commit into from Oct 27, 2021

Conversation

mfn
Copy link
Contributor

@mfn mfn commented Oct 26, 2021

Summary

I used this action as part of a workflow to add code formatted blocks.
Using the guide in the readme I, adjacent spaces where not correctly
preserved, i.e. the following

      - name: yolo
        id: get-comment-body
        run: |
          echo "\`\`\`" > tmp/comment.md
          echo "+--------------+" >> tmp/comment.md
          echo "|This is a test|" >> tmp/comment.md
          echo "+--------------+" >> tmp/comment.md
          echo "|     yolo     |" >> tmp/comment.md
          echo "+--------------+" >> tmp/comment.md
          echo "\`\`\`" >> tmp/comment.md

          cat tmp/comment.md

          # https://github.com/peter-evans/create-or-update-comment#setting-the-comment-body-from-a-file
          body="$(cat tmp/comment.md)"
          body="${body//'%'/'%25'}"
          body="${body//$'\n'/'%0A'}"
          body="${body//$'\r'/'%0D'}"
          echo ::set-output name=body::$body

      - name: Create or update comment
        uses: peter-evans/create-or-update-comment@v1
        with:
          body: ${{ steps.get-comment-body.outputs.body }}
          issue-number: ${{ github.event.pull_request.number }}

produced this

+--------------+
|This is a test|
+--------------+
| yolo |
+--------------+

Adding the double quotes around set-output fixed this:

+--------------+
|This is a test|
+--------------+
|     yolo     |
+--------------+

Further I added double quotes also around the initial cat, because of
this comment https://github.community/t/set-output-truncates-multiline-strings/16852/5

Here are a few observation. First, it is important to suppress word-splitting upon expansion in bash. This is easiest done by enclosing with double quotes:

Thank you!

I used this action as part of a workflow to add code formatted blocks.
Using the guide in the readme I, adjacent spaces where not correctly
preserved, i.e. the following
```
      - name: yolo
        id: get-comment-body
        run: |
          echo "\`\`\`" > tmp/comment.md
          echo "+--------------+" >> tmp/comment.md
          echo "|This is a test|" >> tmp/comment.md
          echo "+--------------+" >> tmp/comment.md
          echo "|     yolo     |" >> tmp/comment.md
          echo "+--------------+" >> tmp/comment.md
          echo "\`\`\`" >> tmp/comment.md

          cat tmp/comment.md

          # https://github.com/peter-evans/create-or-update-comment#setting-the-comment-body-from-a-file
          body="$(cat tmp/comment.md)"
          body="${body//'%'/'%25'}"
          body="${body//$'\n'/'%0A'}"
          body="${body//$'\r'/'%0D'}"
          echo ::set-output name=body::$body

      - name: Create or update comment
        uses: peter-evans/create-or-update-comment@v1
        with:
          body: ${{ steps.get-comment-body.outputs.body }}
          issue-number: ${{ github.event.pull_request.number }}
```
produced this
```
+--------------+
|This is a test|
+--------------+
| yolo |
+--------------+
```
Adding the double quotes around `set-output` fixed this:
```
+--------------+
|This is a test|
+--------------+
|     yolo     |
+--------------+
```
Further I added double quotes also around the initial `cat`, because of
this comment https://github.community/t/set-output-truncates-multiline-strings/16852/5
> Here are a few observation. First, it is important to suppress word-splitting upon expansion in bash. This is easiest done by enclosing with double quotes:
@peter-evans
Copy link
Owner

Thank you! 👍

@peter-evans peter-evans merged commit 85a7ce6 into peter-evans:main Oct 27, 2021
@mfn mfn deleted the mfn-bash-fixes branch October 27, 2021 07:20
Brooooooklyn pushed a commit to rolldown/rolldown that referenced this pull request Mar 9, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [peter-evans/create-or-update-comment](https://togithub.com/peter-evans/create-or-update-comment) | action | major | `v1.4.5` -> `v4.0.0` |

---

### Release Notes

<details>
<summary>peter-evans/create-or-update-comment (peter-evans/create-or-update-comment)</summary>

### [`v4.0.0`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v4.0.0): Create or Update Comment v4.0.0

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v3.1.0...v4.0.0)

⚙️  Updated runtime to Node.js 20

-   The action now requires a minimum version of [v2.308.0](https://togithub.com/actions/runner/releases/tag/v2.308.0) for the Actions runner. Update self-hosted runners to v2.308.0 or later to ensure compatibility.

#### What's Changed

-   build(deps): bump actions/setup-node from 3 to 4 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#273
-   build(deps-dev): bump [@&#8203;vercel/ncc](https://togithub.com/vercel/ncc) from 0.38.0 to 0.38.1 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#274
-   build(deps-dev): bump eslint-plugin-jest from 27.4.2 to 27.4.3 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#276
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.18.5 to 18.18.6 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#277
-   build(deps-dev): bump eslint from 8.51.0 to 8.52.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#275
-   build(deps-dev): bump eslint-plugin-jest from 27.4.3 to 27.6.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#278
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.18.6 to 18.18.8 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#279
-   build(deps-dev): bump eslint from 8.52.0 to 8.53.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#280
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.18.8 to 18.18.9 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#281
-   build(deps-dev): bump prettier from 3.0.3 to 3.1.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#282
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.18.9 to 18.18.12 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#283
-   build(deps-dev): bump eslint from 8.53.0 to 8.54.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#284
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.18.12 to 18.18.13 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#285
-   build(deps-dev): bump eslint from 8.54.0 to 8.55.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#286
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.18.13 to 18.19.2 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#287
-   build(deps): bump chuhlomin/render-template from 1.8 to 1.9 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#288
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.19.2 to 18.19.3 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#289
-   build(deps-dev): bump prettier from 3.1.0 to 3.1.1 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#290
-   build(deps-dev): bump eslint-plugin-prettier from 5.0.1 to 5.1.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#292
-   build(deps-dev): bump eslint from 8.55.0 to 8.56.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#293
-   build(deps): bump actions/download-artifact from 3 to 4 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#295
-   build(deps-dev): bump eslint-plugin-prettier from 5.1.0 to 5.1.2 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#296
-   build(deps-dev): bump eslint-plugin-jest from 27.6.0 to 27.6.1 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#297
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.19.3 to 18.19.4 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#298
-   build(deps-dev): bump eslint-plugin-prettier from 5.1.2 to 5.1.3 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#299
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.19.4 to 18.19.6 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#300
-   build(deps-dev): bump prettier from 3.1.1 to 3.2.3 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#301
-   build(deps-dev): bump eslint-plugin-jest from 27.6.1 to 27.6.3 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#302
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.19.6 to 18.19.7 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#303
-   build(deps-dev): bump [@&#8203;types/node](https://togithub.com/types/node) from 18.19.7 to 18.19.8 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#304
-   build(deps-dev): bump prettier from 3.2.3 to 3.2.4 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#305
-   feat: update runtime to node 20 by [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#306

**Full Changelog**: peter-evans/create-or-update-comment@v3.1.0...v4.0.0

### [`v3.1.0`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v3.1.0): Create or Update Comment v3.1.0

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v3.0.2...v3.1.0)

#### What's Changed

-   Add truncate warning to body of comment by [@&#8203;ethanmdavidson](https://togithub.com/ethanmdavidson) and [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#272
-   46 dependency updates by [@&#8203;dependabot](https://togithub.com/dependabot)

**Full Changelog**: peter-evans/create-or-update-comment@v3.0.2...v3.1.0

### [`v3.0.2`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v3.0.2): Create or Update Comment v3.0.2

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v3.0.1...v3.0.2)

#### What's Changed

-   Truncate long comment bodies during comment update too by [@&#8203;Dermah](https://togithub.com/Dermah) in [peter-evans/create-or-update-comment#205
-   Update distribution by [@&#8203;actions-bot](https://togithub.com/actions-bot) in [peter-evans/create-or-update-comment#210
-   23 dependency updates by [@&#8203;dependabot](https://togithub.com/dependabot)

#### New Contributors

-   [@&#8203;Dermah](https://togithub.com/Dermah) made their first contribution in [peter-evans/create-or-update-comment#205

**Full Changelog**: peter-evans/create-or-update-comment@v3.0.1...v3.0.2

### [`v3.0.1`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v3.0.1): Create or Update Comment v3.0.1

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v3.0.0...v3.0.1)

#### What's Changed

-   fix: find-comment version by [@&#8203;ematipico](https://togithub.com/ematipico) in [peter-evans/create-or-update-comment#164
-   fix: truncate body when it exceeds the max length by [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#182
-   12 dependency updates by [@&#8203;dependabot](https://togithub.com/dependabot)

#### New Contributors

-   [@&#8203;ematipico](https://togithub.com/ematipico) made their first contribution in [peter-evans/create-or-update-comment#164

**Full Changelog**: peter-evans/create-or-update-comment@v3.0.0...v3.0.1

### [`v3.0.0`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v3.0.0): Create or Update Comment v3.0.0

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v2.1.1...v3.0.0)

#### What's new

-   Now supports replacing reactions on a comment by setting input `reactions-edit-mode` to `replace`. The default behaviour has not changed and will `append` reactions.
-   Chose how the action should append the comment body with input `append-separator`. The default behaviour is to add a `newline`. Other options are `space` and `none`.
-   `body-file` is deprecated in favour of `body-path`. The behaviour is unchanged.

#### What's Changed

-   v3 by [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#161
-   Update some links in the README by [@&#8203;Kurt-von-Laven](https://togithub.com/Kurt-von-Laven) in [peter-evans/create-or-update-comment#152
-   9 dependency updates by [@&#8203;dependabot](https://togithub.com/dependabot)

#### New Contributors

-   [@&#8203;Kurt-von-Laven](https://togithub.com/Kurt-von-Laven) made their first contribution in [peter-evans/create-or-update-comment#152

**Full Changelog**: peter-evans/create-or-update-comment@v2.1.1...v3.0.0

### [`v2.1.1`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v2.1.1): Create or Update Comment v2.1.1

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v2.1.0...v2.1.1)

⚙️ Fixes the recent Json5 vulnerability.

#### What's Changed

-   11 dependency updates by [@&#8203;dependabot](https://togithub.com/dependabot)

**Full Changelog**: peter-evans/create-or-update-comment@v2.1.0...v2.1.1

### [`v2.1.0`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v2.1.0): Create or Update Comment v2.1.0

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v2.0.1...v2.1.0)

⭐ Adds input `body-file`, the path to a file containing the comment body.

#### What's Changed

-   Replace set-output by [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#130
-   Bump chuhlomin/render-template from 1.5 to 1.6 by [@&#8203;dependabot](https://togithub.com/dependabot) in [peter-evans/create-or-update-comment#132
-   Support reading body from a file by [@&#8203;umanghome](https://togithub.com/umanghome) in [peter-evans/create-or-update-comment#115
-   Add input body-file by [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#133

#### New Contributors

-   [@&#8203;umanghome](https://togithub.com/umanghome) made their first contribution in [peter-evans/create-or-update-comment#115

**Full Changelog**: peter-evans/create-or-update-comment@v2.0.1...v2.1.0

### [`v2.0.1`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v2.0.1): Create or Update Comment v2.0.1

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v2.0.0...v2.0.1)

⚙️ Bumps `@actions/core` to transition away from [deprecated runner commands](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/).

#### What's Changed

-   Add workflow permissions by [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#120
-   9 dependency updates by [@&#8203;github-actions](https://togithub.com/github-actions) and https://github.com/dependabot

**Full Changelog**: peter-evans/create-or-update-comment@v2.0.0...v2.0.1

### [`v2.0.0`](https://togithub.com/peter-evans/create-or-update-comment/releases/tag/v2.0.0): Create or Update Comment v2.0.0

[Compare Source](https://togithub.com/peter-evans/create-or-update-comment/compare/v1.4.5...v2.0.0)

#### What's new

-   Updated runtime to Node.js 16
    -   The action now requires a minimum version of v2.285.0 for the [Actions Runner](https://togithub.com/actions/runner/releases/tag/v2.285.0).
    -   If using GitHub Enterprise Server, the action requires [GHES 3.4](https://docs.github.com/en/enterprise-server@3.4/admin/release-notes) or later.

#### What's Changed

-   Use double quotes to preserve adjacent spaces correctly by [@&#8203;mfn](https://togithub.com/mfn) in [peter-evans/create-or-update-comment#95
-   Remove workflow by [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#101
-   Update runtime to node 16 by [@&#8203;peter-evans](https://togithub.com/peter-evans) in [peter-evans/create-or-update-comment#105
-   7 dependency updates by [@&#8203;actions-bot](https://togithub.com/actions-bot) and [@&#8203;dependabot](https://togithub.com/dependabot)

#### New Contributors

-   [@&#8203;mfn](https://togithub.com/mfn) made their first contribution in [peter-evans/create-or-update-comment#95

**Full Changelog**: peter-evans/create-or-update-comment@v1.4.5...v2.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/rolldown-rs/rolldown).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIzMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants