Repository navigation
Closed
Labels
bugSomething isn't workinggh-releaserelating to the gh release commandhelp wantedContributions welcomepriority-3Affects a small number of users or is largely cosmetic
Description
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
- create an annotated tag which has newlines
- create a release using
gh release ... --notes-from-tag - the release it creates will have the content of the annotated tag but without the newlines
Expected vs actual behavior
See above.
Logs
Example:
- for public repo https://github.com/diffplug/blowdryer-diffplug
git show 8.0.0
tag 8.0.0
Tagger: runner <runner@fv-az775-255.ywbp5beigl5e3k0catohwgwj5f.cx.internal.cloudapp.net>
Date: Mon Jul 8 20:32:56 2024 +0000
### Changed
- **BREAKING** `spotlessChangelog` now creates GitHub releases by default ([#6](https://github.com/diffplug/blowdryer-diffplug/pull/6))
- you need to update your `deploy.yml`
- if you set the `tagPrefix`, then you'll need to update the `runAfterPush`
- see PR above for details
commit c642275aebd3ce915fbd4a471117169e164c15a0 (tag: 8.0.0, origin/release, release)
gh release create '8.0.0' --title '8.0.0' --notes-from-taggh release view 8.0.0
8.0.0
nedtwigg released this about 5 minutes ago
### Changed - BREAKING spotlessChangelog now creates GitHub releases by default (#6
https://github.com/diffplug/blowdryer-diffplug/pull/6) - you need to update your deploy.yml - if you set the
tagPrefix , then you'll need to update the runAfterPush - see PR above for details
View on GitHub: https://github.com/diffplug/blowdryer-diffplug/releases/tag/8.0.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workinggh-releaserelating to the gh release commandhelp wantedContributions welcomepriority-3Affects a small number of users or is largely cosmetic
Activity
williammartin commentedon Jul 18, 2024
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 here
I 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
contents:subjectline works.I'm just concerned that if we used
%(contents)we might end up with extra unexpected stuff in the message.sizeclearly doesn't appear, but what aboutsignature? I don't have an example to check right now. Unfortunately there's no information in the original PR as to why we focused only onsubjectandbody.babakks commentedon Jul 21, 2024
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
\ns) before the first blank line (like commit messages). For example, if you create the tag with this command then the subject and the body are all correctly assigned:But if you do it like this, it will end up with the same issue:
Alternatively, using
%(content)will include extra stuff as you suggested. Here's the result with a signature (i.e., tag was created with the-soption):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
%(contents)only when%(contents:body)is empty, but it's not good enough. For example, if a tag annotation looks like below then such a solution wouldn't work.Conclusion
I really don't know what's the best way to resolve this issue. So far we should either:
%(contents)field value and strip the extra parts, which should also keep the current behavior for well-formatted subject/body tag annotations.@williammartin What do you think?
williammartin commentedon Jul 22, 2024
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
/tagsURL for this repo and we expand the tag, we don't see the signature: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
git cat-filewith some regex applied to split headers from the body, or via the rugged gem. In either case the result is the same, the contents of themessageproperty on ourTagmodel contains the signature as we'd expect:Then, given this
messageproperty, a regex is applied to split the signature from the rest:Where the constants are:
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
$(contents)and apply a similar regex stripping operation in the CLI.nedtwigg commentedon Jul 23, 2024
From the standpoint of an end-user
--notes-from-tagcould take an optional argument, e.e.g--notes-from-tag gh-format--notes-from-tag %(contents:subject)%0a%0a%(contents:body)babakks commentedon Jul 25, 2024
@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.
babakks commentedon Jul 29, 2024
@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.
williammartin commentedon Jul 30, 2024
I'm on vacation until the middle of August. I'm happy to review on my return if Andy doesn't want to. ✌
Tag message now has the `v{{version}}\n\n{changes}` format, as workar…
andyfeller commentedon Aug 6, 2024
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.
Fix from knowledge in cli/cli#9299
We don't need to workaround cli/cli#9299 anymore.