Skip to content

Add newline to body when viewing machine readable release#6108

Merged
samcoe merged 1 commit intocli:trunkfrom
wheelerlaw:add-newline-when-vieweing-machine-readable-release-body
Aug 31, 2022
Merged

Add newline to body when viewing machine readable release#6108
samcoe merged 1 commit intocli:trunkfrom
wheelerlaw:add-newline-when-vieweing-machine-readable-release-body

Conversation

@wheelerlaw
Copy link
Contributor

@wheelerlaw wheelerlaw commented Aug 19, 2022

Problem statement:

If a release does not have a newline at the end of its body, that will affect the way the gh command prints its output in a machine-readable format and results in the next command's output being printed on the same line. This is undesirable even if the body has no trailing newline.

For example, given the following commands:

gh release view
echo "Hello world"

...the output will be:

title:	test-release
tag:	test-release
draft:	false
prerelease:	false
author:	wheelerlaw
created:	2022-08-19T00:46:52Z
published:	2022-08-19T15:38:46Z
url:	https://github.com/wheelerlaw/example/releases/tag/test-release
--
testHello world!

...when it should be:

title:	test-release
tag:	test-release
draft:	false
prerelease:	false
author:	wheelerlaw
created:	2022-08-19T00:46:52Z
published:	2022-08-19T15:38:46Z
url:	https://github.com/wheelerlaw/example/releases/tag/test-release
--
test
Hello world!

No only is this behavior undesirable, it is inconsistent with the way the release is printed when viewed in the human readable format. For example, given the exact same commands (but run in a TTY), the output will print 2 new lines below the release body regardless if it has a trailing newline:

test-release
wheelerlaw released this about 2 hours ago

  test                                                                        


View on GitHub: https://github.com/wheelerlaw/example/releases/tag/test-release

Proposed change:

This fix prints a newline at the end of the release regardless if the release body has a newline or not, by checking to see if a newline is present at the end of the body and if not, printing one.

@wheelerlaw wheelerlaw requested a review from a team as a code owner August 19, 2022 18:31
@wheelerlaw wheelerlaw requested review from samcoe and removed request for a team August 19, 2022 18:31
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Aug 19, 2022
@cliAutomation
Copy link
Collaborator

Hi! Thanks for the pull request. Please ensure that this change is linked to an issue by mentioning an issue number in the description of the pull request. If this pull request would close the issue, please put the word 'Fixes' before the issue number somewhere in the pull request body. If this is a tiny change like fixing a typo, feel free to ignore this message.

@samcoe samcoe self-assigned this Aug 22, 2022
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thanks for adding tests!

@samcoe samcoe merged commit 8cd9641 into cli:trunk Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants