git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 11/11] contrib: related: add support for mailmap

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 25, 2013, 19:59 UTC
Message-ID
<1366919983-27521-12-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1366919983-27521-1-git-send-email-felipe.contreras@gmail.com>
This seems to be the way git tools do it.
Suggested-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/related/git-related | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
diff --git a/contrib/related/git-related b/contrib/related/git-related
index f85e924..be263e2 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -7,6 +7,8 @@ $min_percent = 5
 $show_commits = false
 $files = []
 $rev_args = []
+$mailmaps = {}
+$mailmaps_complex = {}
 
 begin
   OptionParser.new do |opts|
@@ -27,6 +29,39 @@ rescue OptionParser::InvalidOption => e
   $rev_args += e.args
 end
 
+def get_mailmap(filename)
+  return unless File.exists?(filename)
+  File.open(filename) do |f|
+    f.each do |line|
+      case line.gsub(/\s*#.*$/, '')
+      when /^([^<>]+)\s+<(\S+)>$/
+        $mailmaps[$2] = [ $1, nil ]
+      when /^<(\S+)>\s+<(\S+)>$/
+        $mailmaps[$2] = [ nil, $1 ]
+      when /^([^<>]+)\s+<(\S+)>\s+<(\S+)>$/
+        $mailmaps[$3] = [ $1, $2 ]
+      when /^([^<>]+)\s+<(\S+)>\s+([^<>]+)\s+<(\S+)>$/
+        $mailmaps_complex[[$3, $4]] = [ $1, $2 ]
+      end
+    end
+  end
+end
+
+def mailmap_fix(person)
+  new = nil
+  name, email = person
+  new = $mailmaps_complex[person] if not new and $mailmaps_complex.include?(person)
+  new = $mailmaps[email] if not new and $mailmaps.include?(email)
+  return if not new
+  person[0] = new[0] if new[0]
+  person[1] = new[1] if new[1]
+end
+
+get_aliases if $get_aliases
+get_mailmap('.mailmap')
+mailmap_file = %x[git config mailmap.file].chomp
+get_mailmap(mailmap_file)
+
 KNOWN_ROLES = {
   'Signed-off' => :signer,
   'Reviewed' => :reviewer,
@@ -65,6 +100,7 @@ class Commit
       end
     end
     @roles = roles.map do |person, roles|
+      mailmap_fix(person)
       [person, roles]
     end
   end
-- 
1.8.2.1
Previous: Felipe Contreras
Message 17 of 17 in “Add new git-related helper to contrib”
  1. 00/11 Add new git-related helper to contribFelipe Contreras, Apr 25, 2013
  2. 01/11 Add new git-related helper to contribFelipe Contreras, Apr 25, 2013
  3. Felipe ContrerasApr 26, 2013
  4. Junio C HamanoApr 26, 2013
  5. Felipe ContrerasApr 26, 2013
  6. Ramkumar RamachandraApr 27, 2013
  7. Felipe ContrerasMay 13, 2013
  8. 02/11 contrib: related: add option parsingFelipe Contreras, Apr 25, 2013
  9. 03/11 contrib: related: add support for multiple patchesFelipe Contreras, Apr 25, 2013
  10. 04/11 contrib: related: add option to show commitsFelipe Contreras, Apr 25, 2013
  11. 05/11 contrib: related: add option to parse from committishFelipe Contreras, Apr 25, 2013
  12. 06/11 contrib: related: parse committish like format-patchFelipe Contreras, Apr 25, 2013
  13. 07/11 contrib: related: fix parsing of rev-list argsFelipe Contreras, Apr 25, 2013
  14. 08/11 contrib: related: support multiple rolesFelipe Contreras, Apr 25, 2013
  15. 09/11 contrib: related: sort by participationFelipe Contreras, Apr 25, 2013
  16. 10/11 contrib: related: group persons with same emailFelipe Contreras, Apr 25, 2013
  17. 11/11 contrib: related: add support for mailmapFelipe Contreras, Apr 25, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.