-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
--notes-from-tag
does not preserve newlines
#9299
Comments
Hmmmm, interesting. So here's how we load the notes from an annotated tag:
For your tag this shows:
And if we look a bit closer, we can see that your entire annotation is being treated as the subject line:
Comparatively, if we actually have a subject line, things look correct:
What do we do from hereI wonder if we should be using:
It definitely seems like if you wrote a tag annotation message with newlines, those should be preserved, regardless of how I'm just concerned that if we used |
Here is my two cents on this.
@williammartin I think the tag message is not well-formatted as of Git definitions. Git seems to create the subject line as single-line concatenation of all text (including single $ git tag -a -F <(echo "subject\n\nfoo\nbar\nbaz") v1
$ git tag --list v1 --format='%(contents:subject)' | cat
subject
$ git tag --list v1 --format='(contents:body)' | cat
foo
bar
baz But if you do it like this, it will end up with the same issue: $ git tag -a -F <(echo "subject line 1\nsubject line 2\n\nfoo\nbar\nbaz") v2
$ git tag --list v2 --format='%(contents:subject)' | cat
subject line 1 subject line 2
$ git tag --list v2 --format='(contents:body)' | cat
foo
bar
baz Alternatively, using
Truncating signature from the text is not impossible but doesn't seem like the best way to do it. You should also delete other extra things, if any. Also, this approach has to be backward-compatible with the existing behavior and keep the same output format for well-formated subject/body annotations. I also thought of other small improvements, like using
ConclusionI really don't know what's the best way to resolve this issue. So far we should either:
@williammartin What do you think? |
Alright so I went into a bit of a rabbit-hole on this one, bear with me. How does github.com display annotated tag messages?Here's a new tag with a signature:
If we go to the So we can see that the platform has some mechanism of pulling the information we want with newlines preserved. How does github.com do this?Well, I had a look into the codebase and I could see that these contents were either loaded via
Then, given this def extract_tag_signature(message)
if message.nil?
[nil, false]
elsif !message.valid_encoding?
[message, false]
elsif message.match(/^#{GPG_SIGNATURE_PREFIX}$/)
message = message.split("#{GPG_SIGNATURE_PREFIX}\n", 2).first
[message, true]
elsif message.match(/^#{SSH_SIGNATURE_PREFIX}$/)
message = message.split("#{SSH_SIGNATURE_PREFIX}\n", 2).first
[message, true]
elsif message.match(/^#{SMIME_SIGNATURE_PREFIX}$/)
message = message.split("#{SMIME_SIGNATURE_PREFIX}\n", 2).first
[message, true]
else
[message, false]
end
end Where the constants are: GPG_SIGNATURE_PREFIX = "-----BEGIN PGP SIGNATURE-----".freeze
SMIME_SIGNATURE_PREFIX = "-----BEGIN SIGNED MESSAGE-----".freeze
SSH_SIGNATURE_PREFIX = "-----BEGIN SSH SIGNATURE-----".freeze So what should we do?I believe that we should honour annotated messages as they are written. I have more confidence in following the platform's example than any other approach to doing so. Therefore I believe we should use |
From the standpoint of an end-user
|
@nedtwigg I'm glad your issue is resolved. And yes, I too think adding the format argument just complicates things. @williammartin Thanks for the investigation. I agree about the user experience, and it'll be nice to make it work just like the platform does. I'll submit a PR for this soon. I think the important part is for the changes to keep the current behavior intact for well-formatted annotations. |
@williammartin I've submitted the PR for this. @andyfeller is already assigned for a review, but since you've already investigated this it'd be great to also have your review. |
I'm on vacation until the middle of August. I'm happy to review on my return if Andy doesn't want to. ✌ |
Firstly, great write up in the issue; makes sense, easy to follow, and I'm familiar with the topic so I'm comfortable reviewing. I had a few questions that aren't huge blockers, so will work to ensure we get @babakks PR shipped asap. |
Describe the bug
If an annotated tag has newlines,
--notes-from-tag
should preserve those newlines in the created release, but it strips all newlines.Steps to reproduce the behavior
gh release ... --notes-from-tag
Expected vs actual behavior
See above.
Logs
Example:
git show 8.0.0
gh release create '8.0.0' --title '8.0.0' --notes-from-tag
gh release view 8.0.0
The text was updated successfully, but these errors were encountered: