From 4d69c315e8b973ba08ae7a9592935565359fd1d2 Mon Sep 17 00:00:00 2001 From: filodej Date: Fri, 29 Mar 2013 16:02:48 +0100 Subject: [PATCH 1/8] Remove Author.email field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For example "John Smith " and "John Smith " are considered as a single author regardless of the different email addresses. This change is just a workaround. But as the URL for author details is constructed from Autor.dirname (as opposed to Author.email - see dc4d2a08) the original version does not work anyway. This seems to me as a suitable quickfix until the whole issue is properly addressed. --- lib/git_stats/git_data/author.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/git_stats/git_data/author.rb b/lib/git_stats/git_data/author.rb index 1c0f714b17..08c7763fc9 100644 --- a/lib/git_stats/git_data/author.rb +++ b/lib/git_stats/git_data/author.rb @@ -6,7 +6,7 @@ module GitData class Author include HashInitializable - attr_reader :repo, :name, :email + attr_reader :repo, :name def commits @commits ||= repo.commits.select { |commit| commit.author == self } @@ -55,11 +55,11 @@ def dirname end def to_s - "#{self.class} #@name <#@email>" + "#{self.class} #@name" end def ==(other) - [self.repo, self.name, self.email] == [other.repo, other.name, other.email] + self.name == other.name end end From 62003af6ccde5a3ce9773d3cbc61f4d10d302573 Mon Sep 17 00:00:00 2001 From: filodej Date: Fri, 29 Mar 2013 16:09:04 +0100 Subject: [PATCH 2/8] Build commits by author name instead of email --- lib/git_stats/git_data/repo.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/git_stats/git_data/repo.rb b/lib/git_stats/git_data/repo.rb index c218aaa7ca..29805047e7 100644 --- a/lib/git_stats/git_data/repo.rb +++ b/lib/git_stats/git_data/repo.rb @@ -18,18 +18,18 @@ def initialize(params) def authors @authors ||= run_and_parse("git shortlog -se #{commit_range}").map do |author| - Author.new(repo: self, name: author[:name], email: author[:email]) + Author.new(repo: self, name: author[:name]) end.extend(ByFieldFinder) end def commits - @commits ||= run_and_parse("git rev-list --pretty=format:'%h|%at|%ai|%aE' #{commit_range} | grep -v commit").map do |commit_line| + @commits ||= run_and_parse("git rev-list --pretty=format:'%h|%at|%ai|%aN' #{commit_range} | grep -v commit").map do |commit_line| Commit.new( repo: self, sha: commit_line[:sha], stamp: commit_line[:stamp], date: DateTime.parse(commit_line[:date]), - author: authors.by_email(commit_line[:author_email]) + author: authors.by_name(commit_line[:author_name]) ) end.sort_by! { |e| e.date }.extend(ByFieldFinder) end From ae8fcfb1e7cc48b8184aab296dfd5e985335df97 Mon Sep 17 00:00:00 2001 From: filodej Date: Fri, 29 Mar 2013 16:09:51 +0100 Subject: [PATCH 3/8] Remove author.email from the _authors.haml template --- templates/authors/_authors.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/authors/_authors.haml b/templates/authors/_authors.haml index bdeac9bcc1..c14c34d7c9 100644 --- a/templates/authors/_authors.haml +++ b/templates/authors/_authors.haml @@ -31,7 +31,7 @@ - sorted_authors.each_with_index do |author, i| %tr %th= i+1 - %th= "#{author.name} <#{author.email}>" + %th= "#{author.name}" %td= author.commits.size %td= author.insertions %td= author.deletions From 03273ee6f0f48633f369308aa30047c496693c86 Mon Sep 17 00:00:00 2001 From: filodej Date: Fri, 29 Mar 2013 16:15:46 +0100 Subject: [PATCH 4/8] Parse author name instead of email from revision list --- lib/git_stats/git_data/command_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git_stats/git_data/command_parser.rb b/lib/git_stats/git_data/command_parser.rb index 756fd6a0ec..88c260eb7d 100644 --- a/lib/git_stats/git_data/command_parser.rb +++ b/lib/git_stats/git_data/command_parser.rb @@ -23,8 +23,8 @@ def parse_ls_tree(result, params) def parse_rev_list(result, params) result.lines.map do |line| - sha, stamp, date, author_email = line.split('|').map(&:strip) - {sha: sha, stamp: stamp, date: date, author_email: author_email} + sha, stamp, date, author_name = line.split('|').map(&:strip) + {sha: sha, stamp: stamp, date: date, author_name: author_name} end end From b477a7c59554474144c9a4f997f0effd9961d9c8 Mon Sep 17 00:00:00 2001 From: filodej Date: Fri, 29 Mar 2013 16:25:33 +0100 Subject: [PATCH 5/8] Include back the .repo member to the Author comparison --- lib/git_stats/git_data/author.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git_stats/git_data/author.rb b/lib/git_stats/git_data/author.rb index 08c7763fc9..79971170e5 100644 --- a/lib/git_stats/git_data/author.rb +++ b/lib/git_stats/git_data/author.rb @@ -59,7 +59,7 @@ def to_s end def ==(other) - self.name == other.name + [self.repo, self.name] == [other.repo, other.name] end end From c72e15d583e112547c3eedc989aa3a9c758c1aa9 Mon Sep 17 00:00:00 2001 From: filodej Date: Fri, 29 Mar 2013 16:28:42 +0100 Subject: [PATCH 6/8] Remove .email access from the _activity.haml --- templates/activity/_activity.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/activity/_activity.haml b/templates/activity/_activity.haml index 6b439ef51f..b8c932102c 100644 --- a/templates/activity/_activity.haml +++ b/templates/activity/_activity.haml @@ -19,7 +19,7 @@ .tab-pane.active .page-header.pagination-centered %h1= page.t - %h3= "#{author.respond_to?(:name) ? author.name : ""} #{author.respond_to?(:email) ? "<#{author.email}>" : ""}" + %h3= author.respond_to?(:name) ? author.name : "" - if page == :activity_by_date = high_stock("charts.activity_by_date", charts.activity_by_date(author)) @@ -98,4 +98,4 @@ %tr %th= year - (1..12).each do |month| - %td= months[month] \ No newline at end of file + %td= months[month] From 5bc8e7c5ff8c94f7322818ecb9cc2fe5d1ff39b5 Mon Sep 17 00:00:00 2001 From: filodej Date: Sat, 30 Mar 2013 11:03:45 +0100 Subject: [PATCH 7/8] Run git shortlog just with author names (no emails) --- lib/git_stats/git_data/repo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git_stats/git_data/repo.rb b/lib/git_stats/git_data/repo.rb index 29805047e7..d782d7216b 100644 --- a/lib/git_stats/git_data/repo.rb +++ b/lib/git_stats/git_data/repo.rb @@ -17,7 +17,7 @@ def initialize(params) end def authors - @authors ||= run_and_parse("git shortlog -se #{commit_range}").map do |author| + @authors ||= run_and_parse("git shortlog -s #{commit_range}").map do |author| Author.new(repo: self, name: author[:name]) end.extend(ByFieldFinder) end From c236b842863383906aa31a582cd9d8af4ac739ac Mon Sep 17 00:00:00 2001 From: filodej Date: Sat, 30 Mar 2013 11:04:28 +0100 Subject: [PATCH 8/8] Parse git shortlog with author names (no emails) --- lib/git_stats/git_data/command_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git_stats/git_data/command_parser.rb b/lib/git_stats/git_data/command_parser.rb index 88c260eb7d..f6830db969 100644 --- a/lib/git_stats/git_data/command_parser.rb +++ b/lib/git_stats/git_data/command_parser.rb @@ -9,8 +9,8 @@ def parse(command, result) def parse_shortlog(result, params) result.lines.map do |line| - commits, name, email = line.scan(/(.*)\t(.*)<(.*)>/).first.map(&:strip) - {commits: commits.to_i, name: name, email: email} + commits, name = line.scan(/(.*)\t(.*)/).first.map(&:strip) + {commits: commits.to_i, name: name} end end