app/helpers/shipit/stacks_helper.rb in shipit-engine-0.15.0 vs app/helpers/shipit/stacks_helper.rb in shipit-engine-0.16.0

- old
+ new

@@ -31,31 +31,46 @@ link_to(t("deploy_button.caption.#{commit.deploy_state(bypass_safeties?)}"), url, class: classes, data: data) end def github_change_url(commit) - commit.pull_request_url || github_commit_url(commit) + if commit.pull_request? + github_pull_request_url(commit) + else + github_commit_url(commit) + end end - def render_commit_message(commit) - message = commit.pull_request_title || commit.message - content_tag(:span, emojify(message.truncate(COMMIT_TITLE_LENGTH)), class: 'event-message') + def render_commit_message(pull_request_or_commit) + message = pull_request_or_commit.title.to_s.truncate(COMMIT_TITLE_LENGTH) + content_tag(:span, emojify(message), class: 'event-message') end + def render_pull_request_title_with_link(pull_request) + message = render_commit_message(pull_request) + link_to(message, github_pull_request_url(pull_request), target: '_blank') + end + def render_commit_message_with_link(commit) - link_to(render_commit_message(commit), github_change_url(commit), target: '_blank') + message = render_commit_message(commit) + link_to(message, github_change_url(commit), target: '_blank') end def render_commit_id_link(commit) if commit.pull_request? pull_request_link(commit) + " (#{render_raw_commit_id_link(commit)})".html_safe else render_raw_commit_id_link(commit) end end - def pull_request_link(commit) - link_to("##{commit.pull_request_number}", commit.pull_request_url, target: '_blank', class: 'number') + def pull_request_link(pull_request_or_commit) + number = if pull_request_or_commit.respond_to?(:pull_request_number) + pull_request_or_commit.pull_request_number + else + pull_request_or_commit.number + end + link_to("##{number}", github_pull_request_url(pull_request_or_commit), target: '_blank', class: 'number') end def render_raw_commit_id_link(commit) link_to(commit.short_sha, github_commit_url(commit), target: '_blank', class: 'number') end