Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lib/git_stats/git_data/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def last_commit_sha
@last_commit_sha ||= 'HEAD'
end

def author_emails
@author_emails ||= []
end

def tree_path
@tree_path ||= '.'
end
Expand All @@ -40,21 +44,24 @@ def tree
end

def authors
@authors ||= run_and_parse("git shortlog -se #{commit_range} #{tree_path}").map do |author|
Author.new(repo: self, name: author[:name], email: author[:email])
end
emails = author_emails.map { |email| email.downcase }
@authors ||= run_and_parse("git shortlog -se #{commit_range} #{tree_path}")
.select { |author| emails.count == 0 ? true : emails.include?(author[:email].downcase) }
.map { |author| Author.new(repo: self, name: author[:name], email: author[:email]) }
end

def commits
@commits ||= run_and_parse("git rev-list --pretty=format:'%H|%at|%ai|%aE' #{commit_range} #{tree_path} | grep -v commit").map do |commit_line|
Commit.new(
@commits ||= run_and_parse("git rev-list --pretty=format:'%H|%at|%ai|%aE' #{commit_range} #{tree_path} | grep -v commit")
.select { |commit_line| authors.select { |a| a.email == commit_line[:author_email] } .count > 0 }
.map { |commit_line| Commit.new(
repo: self,
sha: commit_line[:sha],
stamp: commit_line[:stamp],
date: DateTime.parse(commit_line[:date]),
author: authors.first! { |a| a.email == commit_line[:author_email] }
)
end.sort_by! { |e| e.date }
}
.sort_by! { |e| e.date }
end

def commits_period
Expand Down