summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-04-30 04:00:57 +0000
committerGo MAEDA <maeda@farend.jp>2023-04-30 04:00:57 +0000
commitd97beec1d4cc773dd8fb8a5245efb040235f86b1 (patch)
treeddbd3486f207256f3072dfacf3598487792cf5de /lib
parent24fc9a2a8e1b3f8212db890d7f82baf2d7a4b535 (diff)
downloadredmine-d97beec1d4cc773dd8fb8a5245efb040235f86b1.tar.gz
redmine-d97beec1d4cc773dd8fb8a5245efb040235f86b1.zip
Add "View annotation prior to this change" button in the annotate view of Git (#35432).
Patch by Takenori TAKAKI. git-svn-id: https://svn.redmine.org/redmine/trunk@22217 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/scm/adapters/abstract_adapter.rb6
-rw-r--r--lib/redmine/scm/adapters/git_adapter.rb6
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb
index 88a62fd6d..8e74086c5 100644
--- a/lib/redmine/scm/adapters/abstract_adapter.rb
+++ b/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -423,16 +423,18 @@ module Redmine
end
class Annotate
- attr_reader :lines, :revisions
+ attr_reader :lines, :revisions, :previous_annotations
def initialize
@lines = []
@revisions = []
+ @previous_annotations = []
end
- def add_line(line, revision)
+ def add_line(line, revision, previous=nil)
@lines << line
@revisions << revision
+ @previous_annotations << previous
end
def content
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 0c916c283..f4c3902e2 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -376,11 +376,14 @@ module Redmine
identifier = ''
# git shows commit author on the first occurrence only
authors_by_commit = {}
+ prev_blames_by_commit = {}
content.split("\n").each do |line|
if line =~ /^([0-9a-f]{39,40})\s.*/
identifier = $1
elsif line =~ /^author (.+)/
authors_by_commit[identifier] = $1.strip
+ elsif line =~ /^previous (.+)/
+ prev_blames_by_commit[identifier] = $1.strip
elsif line =~ /^\t(.*)/
blame.add_line(
$1,
@@ -389,7 +392,8 @@ module Redmine
:revision => identifier,
:scmid => identifier,
:author => authors_by_commit[identifier]
- )
+ ),
+ prev_blames_by_commit[identifier]
)
identifier = ''
author = ''