-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
release_notes: append #PR to markdown link text #11276
release_notes: append #PR to markdown link text #11276
Conversation
Review period will end on 2021-04-30 at 04:25:19 UTC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this. When merging, the merger does have the option to modify the commit message I believe so it's possible that the people who merged removed that line that is missing. Although, I was the one who merged one of the missing ones and I'm almost positive I didn't touch the merge commit message so it's possible that there's a reason that line's being omitted that isn't coming to me.
I like this solution, though. I wonder, though, if it looks better to use this instead:
Or maybe bold (with or without the colon):
That way the PR number is always first so if the title is missing it's a little more consistent. Plus, it might make a little more sense to have the PR number first anyway.
Also, I don't think we need to rely on a single string interpolation to get this right. If we need to use some more complex logic to change the markdown line if the title is blank we definitely have the room to do so. It might also make it cleaner-looking. For example, only adding the colon and extra spaces if a title is present.
Library/Homebrew/release_notes.rb
Outdated
%r{(.*)/(\d+) \(@(.+)\) - (.*)} =~ s | ||
"- [#{Regexp.last_match(4)} \##{Regexp.last_match(2)}](#{Regexp.last_match(1)}/#{Regexp.last_match(2)})" \ | ||
" (@#{Regexp.last_match(3)})\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%r{(.*)/(\d+) \(@(.+)\) - (.*)} =~ s | |
"- [#{Regexp.last_match(4)} \##{Regexp.last_match(2)}](#{Regexp.last_match(1)}/#{Regexp.last_match(2)})" \ | |
" (@#{Regexp.last_match(3)})\n" | |
matches =~ s.match %r{(?<url>.*)/(?<pr>\d+) \(@(?<user>.+)\) - (?<title>.*)} | |
"- [#{matches[:title]} \##{matches[:pr]}](#{matches[:url]}/#{matches[:pr]})" (@#{matches[:user]})\n" |
I think using named captures will help readability here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your suggestions sound good to me; I'm about to go to bed, so please feel free to push to this branch as you see fit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm about to go to bed
Same here (should have done that hours ago) 🛌😴💤
I'll take a look when I'm available tomorrow if you haven't had a chance yet.
I'd suggest we consider falling back to the first line of the merge commit if the second line isn't present. That at least provides a link to the PR and a branch name that may provide more context. |
so it would look like this: |
to summarize some of the proposed display options: this PR as of 6e91c35: from @Rylan12:
from @MikeMcQuaid |
here's a blend of those proposals that I like: |
Personally I think displaying the PR number is redundant if it's going to be link text. Another option that occurred to me that'd be more involved would be to extract the PR number and query the title from the GitHub API. |
Yeah, I think I agree that including the number just adds extra text that isn't really that useful if there's already a link. I guess we could list the PR only if the description is blank:
Yeah, I wouldn't be opposed to this. We already have the number so it shouldn't be that much more work. Plus it doesn't seem to happen that often so doing an API request every once in a while when |
Review period ended. |
I just added a new test case in fe994a3 for the behavior when a merge commit has a subject message but no body message. Let's use that new test expectation to capture the desired formatting |
I made a quick attempt at updating the regular expression code, but I had some trouble. I won't be able to work on this for a few days. |
end | ||
end | ||
|
||
describe ".generate_release_notes" do | ||
it "generates release notes" do | ||
# rubocop:disable Style/TrailingWhitespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems undesirable to have trailing whitespace generated here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was a placeholder, and it's gone now
end | ||
|
||
it "generates markdown release notes" do | ||
expect(described_class.generate_release_notes("release-notes-testing", "HEAD", markdown: true)).to eq <<~NOTES | ||
- [Do something else](https://github.com/Homebrew/brew/pull/2) (@User) | ||
- [Do something](https://github.com/Homebrew/brew/pull/1) (@Homebrew) | ||
- [ #3](https://github.com/Homebrew/brew/pull/3) (@User) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly this output seems a bit weird. How about Merge pull request #3 from User/another_change
or anything relating to another_change
(as it's a branch name)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used the subject line of the commit if the body is empty (so Merge pull request #3 from User/another_change
)
fe994a3
to
371d679
Compare
I reverted my changes with the PR number but kept the new test case and added code based on @MikeMcQuaid's suggestion to use the subject line of the commit message if the body is missing. I'll leave the approach using the GitHub API for another day. I rebased to clean this up but the commits aren't verified. I tried following the gpg signing guide on my Linux machine, but it's not currently working (my previous commits were verified because I committed through the web browser). I can try to configure my mac with gpg signing and re-push if needed |
371d679
to
944ede4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, nice work here!
Some merge commits don't include the title of the pull request on subsequent lines, leaving the markdown link text blank in the release notes. This appends the subject line of the commit message instead if the body is missing and adds a test case.
944ede4
to
f2c46d4
Compare
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?I noticed in the release notes for 3.1.4 that some lines have an author name but no pull request. As of this writing, the release notes start with the following markdown code (reproduce with
brew ruby -rrelease_notes -e 'puts ReleaseNotes.generate_release_notes("3.1.3", "3.1.4", markdown: true)'
):Notice that the last line has a markdown link to #11129, but it is not rendered because it has no link text. I believe this is because the merge commit for that pull request afa99b4 has only one line of description, while other merge commits, such as 94ce323 for #11263, have an additional line of description.
There are 3 pull requests in 3.1.4 that have this issue. I don't know why these merge commits are like this. As a workaround, I've modified
release_notes.rb
to append an extra#11129
to the Markdown link text. With this change the beginning of the 3.1.4 release notes would have the following markdown: