
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.
38 lines
1.6 KiB
Ruby
38 lines
1.6 KiB
Ruby
# typed: false
|
|
# frozen_string_literal: true
|
|
|
|
require "release_notes"
|
|
|
|
describe ReleaseNotes do
|
|
before do
|
|
HOMEBREW_REPOSITORY.cd do
|
|
system "git", "init"
|
|
system "git", "commit", "--allow-empty", "-m", "Initial commit"
|
|
system "git", "tag", "release-notes-testing"
|
|
system "git", "commit", "--allow-empty", "-m", "Merge pull request #1 from Homebrew/fix", "-m", "Do something"
|
|
system "git", "commit", "--allow-empty", "-m", "make a change"
|
|
system "git", "commit", "--allow-empty", "-m", "Merge pull request #2 from User/fix", "-m", "Do something else"
|
|
system "git", "commit", "--allow-empty", "-m", "another change"
|
|
system "git", "commit", "--allow-empty", "-m", "Merge pull request #3 from User/another_change"
|
|
end
|
|
end
|
|
|
|
describe ".generate_release_notes" do
|
|
it "generates release notes" do
|
|
expect(described_class.generate_release_notes("release-notes-testing", "HEAD")).to eq <<~NOTES
|
|
https://github.com/Homebrew/brew/pull/3 (@User) - Merge pull request #3 from User/another_change
|
|
https://github.com/Homebrew/brew/pull/2 (@User) - Do something else
|
|
https://github.com/Homebrew/brew/pull/1 (@Homebrew) - Do something
|
|
NOTES
|
|
end
|
|
|
|
it "generates markdown release notes" do
|
|
expect(described_class.generate_release_notes("release-notes-testing", "HEAD", markdown: true)).to eq <<~NOTES
|
|
- [Merge pull request #3 from User/another_change](https://github.com/Homebrew/brew/pull/3) (@User)
|
|
- [Do something else](https://github.com/Homebrew/brew/pull/2) (@User)
|
|
- [Do something](https://github.com/Homebrew/brew/pull/1) (@Homebrew)
|
|
NOTES
|
|
end
|
|
end
|
|
end
|