Skip to content

Commit

Permalink
Merge pull request balvig#11 from balvig/release_note
Browse files Browse the repository at this point in the history
allow adding release notes to PR body
  • Loading branch information
balvig authored Apr 7, 2017
2 parents cc648bd + de5469b commit ef09e7d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
14 changes: 12 additions & 2 deletions lib/capistrano/fiesta/story.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def initialize(pr)
@pr = pr
end

def title
@pr.title.sub(/\[Delivers #\S+\]\z/, '').strip
def release_note
(release_note_in_body || title).strip
end

def images
Expand All @@ -20,6 +20,16 @@ def url
def to_markdown
"- [#{title}](#{url})"
end

private

def title
@pr.title.to_s.sub(/\[Delivers #\S+\]\z/, '')
end

def release_note_in_body
@pr.body.to_s[/_Release\snote\:(.+)_/m, 1]
end
end
end
end
4 changes: 2 additions & 2 deletions lib/capistrano/templates/draft.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# <%= comment %>
<% end -%>
<% stories.sort_by(&:title).each do |story| -%>
<%= story.title %>
<% stories.each do |story| -%>
<%= story.release_note %>
<% story.images.each do |image| -%>
<<%= image %>|Screenshot>
<% end -%>
Expand Down
13 changes: 9 additions & 4 deletions test/story_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

module Capistrano::Fiesta
class StoryTest < Minitest::Test
def test_title
def test_title_as_release_note
pr = OpenStruct.new(title: "New [Cool Stuff] feature [Delivers #2123123]")
assert_equal "New [Cool Stuff] feature", Story.new(pr).title
assert_equal "New [Cool Stuff] feature", Story.new(pr).release_note
end

def test_title_with_trello_id
def test_title_with_trello_id_as_release_note
pr = OpenStruct.new(title: "New [Cool Stuff] feature [Delivers #[586f50b384a655b5c009c4ca]")
assert_equal "New [Cool Stuff] feature", Story.new(pr).title
assert_equal "New [Cool Stuff] feature", Story.new(pr).release_note
end

def test_release_note_in_body
pr = OpenStruct.new(body: "_Release note: This thing is amazing_")
assert_equal "This thing is amazing", Story.new(pr).release_note
end

def test_images
Expand Down

0 comments on commit ef09e7d

Please sign in to comment.