Merge branch 'dev_hjq' of http://repository.trustie.net/xianbo/trustie2 into dev_hjq

This commit is contained in:
huang 2015-07-24 16:56:50 +08:00
commit 683456dc3a
2 changed files with 33 additions and 0 deletions

View File

@ -38,6 +38,10 @@ class Repository::Git < Repository
'Git'
end
def commits(authors, start_date, end_date)
scm.commits(authors, start_date, end_date)
end
def report_last_commit
extra_report_last_commit
end

View File

@ -380,6 +380,35 @@ module Redmine
nil
end
def parse_commit(commits)
sum = {file: 0, insertion: 0, deletion: 0}
commits.split("\n").each do |commit|
if /(\d+)\s+?file/ =~ commit
sum[:file] += $1 .to_i
end
if /(\d+)\s+?insertion/ =~ commit
sum[:insertion] += $1.to_i
end
if /(\d+)\s+?deletion/ =~ commit
sum[:deletion] += $1.to_i
end
end
sum[:insertion] + sum[:deletion]
end
def commits(authors, start_date, end_date)
rs = []
authors.each do |author|
cmd_args = %W|log --pretty=tformat: --shortstat --author=#{author} --since=#{start_date} --until=#{end_date}|
commits = ''
git_cmd(cmd_args) do |io|
commits = io.read
end
rs << {author: author, num: parse_commit(commits)}
end
rs
end
class Revision < Redmine::Scm::Adapters::Revision
# Returns the readable identifier
def format_identifier