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

wrap: Avoid trailing whitespace for empty lines #1513

Merged
merged 5 commits into from
Oct 5, 2022

Conversation

abitrolly
Copy link
Contributor

@abitrolly abitrolly commented Oct 3, 2022

What type of PR is this?

  • bug

What this PR does / why we need it:

Linter tools are picky about trailing whitespace, which creates problems when --help output is used in documentation and tests (sourcegraph/scip#97).

Which issue(s) this PR fixes:

(REQUIRED)

Testing

(fill-in or delete this section)

Release Notes

(REQUIRED)


@abitrolly abitrolly requested a review from a team as a code owner October 3, 2022 15:56
mostynb
mostynb previously approved these changes Oct 3, 2022
xwjdsh
xwjdsh previously approved these changes Oct 4, 2022
julian7
julian7 previously requested changes Oct 4, 2022
help.go Outdated Show resolved Hide resolved
@abitrolly abitrolly dismissed stale reviews from xwjdsh and mostynb via 1d26960 October 4, 2022 07:30
@abitrolly
Copy link
Contributor Author

@julian7 any hints why test stared to fail after implementing the last suggestion? There is an extra line generated with that code.

Got:

        NAME:
           
         - add a task to the list
        
        USAGE:
           this is an even longer way
           of describing adding a task
           to the list
        
        DESCRIPTION:
           and a description long
           enough to wrap in this test
           case
        
        OPTIONS:
           --help, -h  show help (default: false)

Expected:

        NAME:
            - add a task to the list
        
        USAGE:
           this is an even longer way
           of describing adding a task
           to the list
        
        DESCRIPTION:
           and a description long
           enough to wrap in this test
           case
        
        OPTIONS:
           --help, -h  show help (default: false)

My only guess that something passes string that is not trimmed to wrap. But I don't see how wrap trimmed the string before. What changes though, is that if an empty string is passed to it, now the newline is returned. Could it be the case?

@abitrolly abitrolly requested a review from julian7 October 4, 2022 10:20
@abitrolly
Copy link
Contributor Author

I refactored code to use slice instead of string buffer. PTAL.

@dearchap
Copy link
Contributor

dearchap commented Oct 4, 2022

@abitrolly Thank you for the PR. Help output is extremely fragile due to the newlines and white spaces etc. The wrap along with the template generates the output and even a slight change in template can create different outputs. If the tests pass that is good enough to merge. Just a heads up though that I have a PR #1506 which fixes a "similar" issue. Please review that as well. Thanks

Copy link
Contributor

@dearchap dearchap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent thanks

@dearchap dearchap dismissed julian7’s stale review October 5, 2022 12:33

Changes committed

@dearchap dearchap merged commit 8335f54 into urfave:main Oct 5, 2022
@abitrolly abitrolly deleted the patch-1 branch October 5, 2022 13:22
another-rex referenced this pull request in google/osv.dev Oct 13, 2022
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/g-rath/osv-detector](https://togithub.com/g-rath/osv-detector)
| require | minor | `v0.7.2` -> `v0.8.0` |
| [github.com/urfave/cli/v2](https://togithub.com/urfave/cli) | require
| minor | `v2.17.1` -> `v2.19.2` |
| [golang.org/x/crypto](https://togithub.com/golang/crypto) | require |
digest | `4161e89` -> `56aed06` |
| [golang.org/x/exp](https://togithub.com/golang/exp) | require | digest
| `b9f4876` -> `4de253d` |

---

### Release Notes

<details>
<summary>g-rath/osv-detector</summary>

###
[`v0.8.0`](https://togithub.com/G-Rath/osv-detector/releases/tag/v0.8.0)

[Compare
Source](https://togithub.com/g-rath/osv-detector/compare/v0.7.2...v0.8.0)

#### What's Changed

- support parsing `poetry.lock`, for Python
([https://github.com/G-Rath/osv-detector/pull/156](https://togithub.com/G-Rath/osv-detector/pull/156))
- support parsing `pubspec.lock`, for Dart
([https://github.com/G-Rath/osv-detector/pull/159](https://togithub.com/G-Rath/osv-detector/pull/159))

**Full Changelog**:
G-Rath/osv-detector@v0.7.2...v0.8.0

</details>

<details>
<summary>urfave/cli</summary>

### [`v2.19.2`](https://togithub.com/urfave/cli/releases/tag/v2.19.2)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.19.1...v2.19.2)

#### What's Changed

- fix: stop automatic sorting for --help by
[@&#8203;FGYFFFF](https://togithub.com/FGYFFFF) in
[https://github.com/urfave/cli/pull/1430](https://togithub.com/urfave/cli/pull/1430)

#### New Contributors

- [@&#8203;FGYFFFF](https://togithub.com/FGYFFFF) made their first
contribution in
[https://github.com/urfave/cli/pull/1430](https://togithub.com/urfave/cli/pull/1430)

**Full Changelog**:
urfave/cli@v2.19.1...v2.19.2

### [`v2.19.1`](https://togithub.com/urfave/cli/releases/tag/v2.19.1)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.19.0...v2.19.1)

#### What's Changed

- Fix:(issue\_1500). Fix slice flag value duplication issue by
[@&#8203;dearchap](https://togithub.com/dearchap) in
[https://github.com/urfave/cli/pull/1502](https://togithub.com/urfave/cli/pull/1502)

**Full Changelog**:
urfave/cli@v2.19.0...v2.19.1

### [`v2.19.0`](https://togithub.com/urfave/cli/releases/tag/v2.19.0)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.18.2...v2.19.0)

#### What's Changed

- Fix:(issue\_1505) Fix flag alignment in help by
[@&#8203;dearchap](https://togithub.com/dearchap) in
[https://github.com/urfave/cli/pull/1506](https://togithub.com/urfave/cli/pull/1506)

**Full Changelog**:
urfave/cli@v2.18.2...v2.19.0

### [`v2.18.2`](https://togithub.com/urfave/cli/releases/tag/v2.18.2)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.18.1...v2.18.2)

#### What's Changed

- Configure GenericFlag's Destination type as struct not pointer by
[@&#8203;nkuba](https://togithub.com/nkuba) in
[https://github.com/urfave/cli/pull/1442](https://togithub.com/urfave/cli/pull/1442)

#### New Contributors

- [@&#8203;nkuba](https://togithub.com/nkuba) made their first
contribution in
[https://github.com/urfave/cli/pull/1442](https://togithub.com/urfave/cli/pull/1442)

**Full Changelog**:
urfave/cli@v2.18.1...v2.18.2

### [`v2.18.1`](https://togithub.com/urfave/cli/releases/tag/v2.18.1)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.18.0...v2.18.1)

#### What's Changed

- Ensure "generate" step runs in CI prior to diff check by
[@&#8203;meatballhat](https://togithub.com/meatballhat) in
[https://github.com/urfave/cli/pull/1504](https://togithub.com/urfave/cli/pull/1504)

**Full Changelog**:
urfave/cli@v2.18.0...v2.18.1

### [`v2.18.0`](https://togithub.com/urfave/cli/releases/tag/v2.18.0)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.17.2...v2.18.0)

#### What's Changed

- Call FlagStringer in String() method of slice flags by
[@&#8203;fjl](https://togithub.com/fjl) in
[https://github.com/urfave/cli/pull/1508](https://togithub.com/urfave/cli/pull/1508)

#### New Contributors

- [@&#8203;fjl](https://togithub.com/fjl) made their first contribution
in
[https://github.com/urfave/cli/pull/1508](https://togithub.com/urfave/cli/pull/1508)

**Full Changelog**:
urfave/cli@v2.17.2...v2.18.0

### [`v2.17.2`](https://togithub.com/urfave/cli/releases/tag/v2.17.2)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.17.1...v2.17.2)

#### What's Changed

- Remove nonexistent phony targets by
[@&#8203;meatballhat](https://togithub.com/meatballhat) in
[https://github.com/urfave/cli/pull/1503](https://togithub.com/urfave/cli/pull/1503)
- wrap: Avoid trailing whitespace for empty lines by
[@&#8203;abitrolly](https://togithub.com/abitrolly) in
[https://github.com/urfave/cli/pull/1513](https://togithub.com/urfave/cli/pull/1513)

#### New Contributors

- [@&#8203;abitrolly](https://togithub.com/abitrolly) made their first
contribution in
[https://github.com/urfave/cli/pull/1513](https://togithub.com/urfave/cli/pull/1513)

**Full Changelog**:
urfave/cli@v2.17.1...v2.17.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am on monday" in timezone
Australia/Sydney, 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.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

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

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/google/osv.dev).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMjIuMyIsInVwZGF0ZWRJblZlciI6IjMyLjIzNC4yIn0=-->

Co-authored-by: Rex P <106129829+another-rex@users.noreply.github.com>
@renovate renovate bot mentioned this pull request Jul 14, 2023
1 task
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.

5 participants