aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2018-04-16 22:32:13 -0400
committerAlec Warner <antarus@gentoo.org>2018-04-16 22:32:13 -0400
commit3a72f426ed692ef796a6b16579d8f6cbafbd89de (patch)
tree5b7786a8483ff545451c44a71ec3796ed50bb96e
parentTry joining with <br> (diff)
downloadpackages-3a72f426ed692ef796a6b16579d8f6cbafbd89de.tar.gz
packages-3a72f426ed692ef796a6b16579d8f6cbafbd89de.tar.bz2
packages-3a72f426ed692ef796a6b16579d8f6cbafbd89de.zip
Fix bug annotations.
Instead of showing the entire commit message, look for glep66 headers in the commit body and pull out the list of bugs. Then annotate each bug # as a link. Then join the links into a list like: 12345,56788,12456 Each number is a link to the bug.
-rw-r--r--app/helpers/packages_helper.rb12
-rw-r--r--app/views/packages/_changelog_entry.html.erb2
2 files changed, 13 insertions, 1 deletions
diff --git a/app/helpers/packages_helper.rb b/app/helpers/packages_helper.rb
index ed90f5d..5f81a4c 100644
--- a/app/helpers/packages_helper.rb
+++ b/app/helpers/packages_helper.rb
@@ -29,6 +29,18 @@ module PackagesHelper
end.join(' ').html_safe
end
+ # This parses commit messages for GLEP66 style bug annotations.
+ # Bug: https://bugs.gentoo.org/NNNNNN
+ # Closes: https://bugs.gentoo.org/NNNNNN
+ def glep66_bugs(commit_msg)
+ bugs_list = []
+ commit_msg.each_line do |line| {
+ bugno = line[/(Bug\:|Closes\:)\s+https:\/\/bugs\.gentoo\.org\/(\d+)/, 1]
+ bugs_list << "https://bugs.gentoo.org/#{bugno}" if !bugno.nil?
+ }
+ bugs_list
+ end
+
def annotate_bugs(str)
annotated_str = str.gsub(/([bB]ug\s+|[bB]ug\s+#|#)(\d+)/) do
link_to_bug("#{$1}#{$2}", $2)
diff --git a/app/views/packages/_changelog_entry.html.erb b/app/views/packages/_changelog_entry.html.erb
index 41c7450..f038ecb 100644
--- a/app/views/packages/_changelog_entry.html.erb
+++ b/app/views/packages/_changelog_entry.html.erb
@@ -1,7 +1,7 @@
<li class="list-group-item">
<strong><%= annotate_bugs changelog[:message].lines.first %></strong>
<br>
- <%= safe_join(changelog[:message].lines[1..-1].map {|line| annotate_bugs line}, '<br>') %>
+ <%= safe_join(glep66_bugs(changelog[:message].lines[1..-1]).each {|l| annotate_bugs l}, ',') %>
<br>
<div class="kk-byline">
<%= mail_to changelog[:email], changelog[:author] %>,