diff options
author | Max Magorsch <arzano@gentoo.org> | 2020-02-20 22:34:25 +0100 |
---|---|---|
committer | Max Magorsch <arzano@gentoo.org> | 2020-02-20 22:36:09 +0100 |
commit | b3b1512a77941c901dbe367b1dfcde63d2be5b0c (patch) | |
tree | e5ef6bd58d0757c23c63c01ee3166505a82fa1e3 | |
parent | Add yarn.lock again (diff) | |
download | packages-5-b3b1512a77941c901dbe367b1dfcde63d2be5b0c.tar.gz packages-5-b3b1512a77941c901dbe367b1dfcde63d2be5b0c.tar.bz2 packages-5-b3b1512a77941c901dbe367b1dfcde63d2be5b0c.zip |
Add information about the committer
So far, only the author infos have been parsed and
displayed. The author and committer (dates) may however
differ largely (especially in case of pull requests).
That's why the committer infos will also be parsed,
stored in the ES index and displayed in the changelog
now.
Signed-off-by: Max Magorsch <arzano@gentoo.org>
-rw-r--r-- | app/controllers/packages_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/links_helper.rb | 17 | ||||
-rw-r--r-- | app/models/commit.rb | 9 | ||||
-rw-r--r-- | app/repositories/commit_repository.rb | 9 | ||||
-rw-r--r-- | app/views/feeds/packages.atom.builder | 2 | ||||
-rw-r--r-- | app/views/packages/_changelog.html.erb | 2 | ||||
-rw-r--r-- | app/views/packages/_changelog_entry.html.erb | 19 | ||||
-rw-r--r-- | lib/portage/util/history.rb | 23 |
8 files changed, 63 insertions, 20 deletions
diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb index 3a4779a..905f9f1 100644 --- a/app/controllers/packages_controller.rb +++ b/app/controllers/packages_controller.rb @@ -42,7 +42,7 @@ class PackagesController < ApplicationController if stale?(etag: @package.updated_at, last_modified: @package.updated_at, public: true) @changelog = Rails.cache.fetch("changelog/#{@package.atom}") do - CommitRepository.find_sorted_by('packages', @package.category + '/' + @package.name, 'date', 'desc', 5) + CommitRepository.find_sorted_by('packages', @package.category + '/' + @package.name, 'committer_date', 'desc', 5) end respond_to do |wants| diff --git a/app/helpers/links_helper.rb b/app/helpers/links_helper.rb index bcdad83..afed16f 100644 --- a/app/helpers/links_helper.rb +++ b/app/helpers/links_helper.rb @@ -1,3 +1,5 @@ +require 'digest/md5' + module LinksHelper # Slash-in-Link-Fix # Replaces the URLencoded slash with a proper slash @@ -12,6 +14,21 @@ module LinksHelper class: 'kk-commit' end + def full_link_to_gitweb_commit(commitid) + link_to commitid, + gitweb_commit_url(commitid), + title: commitid, + class: 'kk-commit' + end + + def gitweb_patch_url(commitid) + 'https://gitweb.gentoo.org/repo/gentoo.git/patch/?id=%s' % commitid + end + + def gravatar_url(email) + 'https://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(email.downcase).to_s + '?s=13&d=retro' + end + def gitweb_commit_url(commitid) 'https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=%s' % commitid end diff --git a/app/models/commit.rb b/app/models/commit.rb index 7989236..0809846 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -3,9 +3,12 @@ class Commit include ActiveModel::Validations ATTRIBUTES = %i[id - author - email - date + author_name + author_email + author_date + committer_name + committer_email + committer_date message files packages diff --git a/app/repositories/commit_repository.rb b/app/repositories/commit_repository.rb index a6e0b33..dc46b71 100644 --- a/app/repositories/commit_repository.rb +++ b/app/repositories/commit_repository.rb @@ -11,9 +11,12 @@ class CommitRepository < BaseRepository mapping dynamic: 'strict' do indexes :id, type: 'keyword' - indexes :author, type: 'keyword' - indexes :email, type: 'keyword' - indexes :date, type: 'date' + indexes :author_name, type: 'keyword' + indexes :author_email, type: 'keyword' + indexes :author_date, type: 'date' + indexes :committer_name, type: 'keyword' + indexes :committer_email, type: 'keyword' + indexes :committer_date, type: 'date' indexes :message, type: 'text' indexes :files do indexes :modified, type: 'keyword' diff --git a/app/views/feeds/packages.atom.builder b/app/views/feeds/packages.atom.builder index ad617b9..776510c 100644 --- a/app/views/feeds/packages.atom.builder +++ b/app/views/feeds/packages.atom.builder @@ -28,7 +28,7 @@ atom_feed(id: atom_id(@feed_type, @feed_id, 'feed')) do |feed| id: atom_id(@feed_type, @feed_id, id), url: absolute_link_to_package(atom) ) do |entry| - entry.updated commit ? commit.date.to_datetime.rfc3339 : Time.now.to_datetime.rfc3339 + entry.updated commit ? commit.author_date.to_datetime.rfc3339 : Time.now.to_datetime.rfc3339 entry.title(t(:feed_keyworded_title, atom: atom, diff --git a/app/views/packages/_changelog.html.erb b/app/views/packages/_changelog.html.erb index b08e2c6..afc10dd 100644 --- a/app/views/packages/_changelog.html.erb +++ b/app/views/packages/_changelog.html.erb @@ -1,4 +1,4 @@ -<div class="card"> +<div class="card mb-4"> <div class="card-header"> <h4 class="mb-0">Changelog</h4> </div> diff --git a/app/views/packages/_changelog_entry.html.erb b/app/views/packages/_changelog_entry.html.erb index b3c1442..c6a2e32 100644 --- a/app/views/packages/_changelog_entry.html.erb +++ b/app/views/packages/_changelog_entry.html.erb @@ -1,9 +1,22 @@ <li class="list-group-item"> <strong><%= annotate_bugs changelog.message.lines.first %></strong> <div class="kk-byline"> - <%= mail_to changelog.email, changelog.author %>, - <%= i18n_date(changelog.date) %>, - commit <%= link_to_gitweb_commit changelog.id%> + <table> + <tr> + <td class="pr-3">author </td> + <td class="pr-3"><img class="rounded-sm inline" src="<%= gravatar_url changelog.author_email %>"> <%= changelog.author_name %> <<%= changelog.author_email %>></td> + <td><%= i18n_date(changelog.author_date) %></td> + </tr> + <tr> + <td class="pr-3">committer </td> + <td class="pr-3"><img class="rounded-sm inline" src="<%= gravatar_url changelog.committer_email %>"> <%= changelog.committer_name%> <<%= changelog.committer_email %>></td> + <td><%= i18n_date(changelog.committer_date) %></td> + </tr> + <tr> + <td class="pr-3">commit </td> + <td colspan="2"><%= full_link_to_gitweb_commit changelog.id%> (<a href="<%= gitweb_patch_url changelog.id%>">patch</a>)</td> + </tr> + </table> </div> <table class="table table-condensed kk-changelog-diffstat"> diff --git a/lib/portage/util/history.rb b/lib/portage/util/history.rb index c6f7111..1e158ff 100644 --- a/lib/portage/util/history.rb +++ b/lib/portage/util/history.rb @@ -6,7 +6,7 @@ class Portage::Util::History return [] if KKULEOMI_DISABLE_GIT == true latest_commit_id = KKULEOMI_FIRST_COMMIT - latest_commit = CommitRepository.n_sorted_by(1, 'date', 'desc').first + latest_commit = CommitRepository.n_sorted_by(1, 'committer_date', 'desc').first latest_commit_id = latest_commit.id unless latest_commit.nil? @@ -14,7 +14,7 @@ class Portage::Util::History .cmd(KKULEOMI_GIT) .in(KKULEOMI_RUNTIME_PORTDIR) .args( - 'log', '--name-status', '--no-merges', '--date=iso8601', '--reverse', + 'log', '--name-status', '--no-merges', '--date=iso8601', '--format=fuller', '--reverse', "#{latest_commit_id}..HEAD") .run @@ -35,10 +35,14 @@ class Portage::Util::History _id = commit_lines.shift.gsub('commit ', '').strip commit_lines.shift =~ /^Author:\s+(.*) <([^>]*)>$/ - _author = $1 - _email = $2 + _author_name = $1 + _author_email = $2 + _author_date = Time.parse(commit_lines.shift[/^AuthorDate:\s+(.*)$/, 1]).utc - _date = Time.parse(commit_lines.shift[/^Date:\s+(.*)$/, 1]).utc + commit_lines.shift =~ /^Commit:\s+(.*) <([^>]*)>$/ + _committer_name = $1 + _committer_email = $2 + _committer_date = Time.parse(commit_lines.shift[/^CommitDate:\s+(.*)$/, 1]).utc commit_lines.shift _raw_message = [] @@ -66,9 +70,12 @@ class Portage::Util::History commit = Commit.new commit.id = _id - commit.author = _author - commit.email = _email - commit.date = _date + commit.author_name = _author_name + commit.author_email = _author_email + commit.author_date = _author_date + commit.committer_name = _committer_name + commit.committer_email = _committer_email + commit.committer_date = _committer_date commit.message = _raw_message.map { |l| l.strip }.join("\n") commit.files = _files commit.packages = _packages.to_set |