diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-02-28 12:09:09 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-02-28 12:09:09 +0000 |
commit | 9a85d4d063e370c5b058328d62d39794f968c90f (patch) | |
tree | 015aa424848b970f721d9f4d59a3365f90ba51a2 /lib | |
parent | d6c299f57d8227745137a62327ed86123682b089 (diff) | |
download | redmine-9a85d4d063e370c5b058328d62d39794f968c90f.tar.gz redmine-9a85d4d063e370c5b058328d62d39794f968c90f.zip |
Fixed: Git blame/annotate fails on moved files (#3832).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3513 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/scm/adapters/git_adapter.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index 75a33a054..ae619e032 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -227,16 +227,25 @@ module Redmine def annotate(path, identifier=nil) identifier = 'HEAD' if identifier.blank? - cmd = "#{GIT_BIN} --git-dir #{target('')} blame -l #{shell_quote identifier} -- #{shell_quote path}" + cmd = "#{GIT_BIN} --git-dir #{target('')} blame -p #{shell_quote identifier} -- #{shell_quote path}" blame = Annotate.new content = nil shellout(cmd) { |io| io.binmode; content = io.read } return nil if $? && $?.exitstatus != 0 # git annotates binary files return nil if content.is_binary_data? + identifier = '' + author = '' content.split("\n").each do |line| - next unless line =~ /([0-9a-f]{39,40})\s\((\w*)[^\)]*\)(.*)/ - blame.add_line($3.rstrip, Revision.new(:identifier => $1, :author => $2.strip)) + if line =~ /^([0-9a-f]{39,40})\s.*/ + identifier = $1 + elsif line =~ /^author (.+)/ + author = $1.strip + elsif line =~ /^\t(.*)/ + blame.add_line($1, Revision.new(:identifier => identifier, :author => author)) + identifier = '' + author = '' + end end blame end |