mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] Add .mailmap file and a tool to maintain it
@ 2014-10-15 12:42 Antony Pavlov
  2014-10-15 12:42 ` [PATCH 1/3] add .mailmap for proper git-shortlog output Antony Pavlov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Antony Pavlov @ 2014-10-15 12:42 UTC (permalink / raw)
  To: barebox

Base on original u-boot patchseries by Masahiro Yamada.

See http://lists.denx.de/pipermail/u-boot/2014-July/183687.html


Antony Pavlov (2):
  add .mailmap for proper git-shortlog output
  Update .mailmap using scripts/mailmapper

Masahiro Yamada (1):
  scripts: add mailmapper, a tool to create/update mailmap file

 .mailmap           |  16 ++++++
 scripts/mailmapper | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 176 insertions(+)
 create mode 100644 .mailmap
 create mode 100755 scripts/mailmapper

-- 
2.1.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] add .mailmap for proper git-shortlog output
  2014-10-15 12:42 [PATCH 0/3] Add .mailmap file and a tool to maintain it Antony Pavlov
@ 2014-10-15 12:42 ` Antony Pavlov
  2014-10-15 12:42 ` [PATCH 2/3] scripts: add mailmapper, a tool to create/update mailmap file Antony Pavlov
  2014-10-15 12:42 ` [PATCH 3/3] Update .mailmap using scripts/mailmapper Antony Pavlov
  2 siblings, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2014-10-15 12:42 UTC (permalink / raw)
  To: barebox; +Cc: Stefan Roese, Wolfgang Denk

Based on original u-boot commit by Masahiro Yamada:

  commit 8b90a11f7cf1d06812bc9a02e0bae20cfe40a564
  Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  Date:   Wed Jul 16 17:49:44 2014 +0900

      add .mailmap for proper git-shortlog output

This is the first version of .mailmap created by hand.
Please see "man git-shortlog" for what this commit is trying to do.

Without this file, for example, "git shortlog -n -s" shows as follows:

  (1)  5428  Sascha Hauer
        968  Jean-Christophe PLAGNIOL-VILLARD
  (2)   811  wdenk
  (2)   525  Wolfgang Denk
        348  Juergen Beisert
           ...
  (3)   154  stroese
  (3)   151  Stefan Roese
           ...
  (1)    48  sascha

And then, with this file, it shows as follows:

  (1)  5476  Sascha Hauer
  (2)  1336  Wolfgang Denk
        968  Jean-Christophe PLAGNIOL-VILLARD
        348  Juergen Beisert
        343  Antony Pavlov
  (3)   305  Stefan Roese

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Stefan Roese <sr@denx.de>
---
 .mailmap | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000..8af4375
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,13 @@
+#
+# This list is used by git-shortlog to fix a few botched name translations
+# in the git archive, either because the author's full name was messed up
+# and/or not always written the same way, making contributions from the
+# same person appearing not to be so or badly displayed.
+#
+# This file can be modified by hand or updated by the following command:
+#  scripts/mailmapper > tmp; mv tmp .mailmap
+#
+
+Sascha Hauer <sascha@nomad.localdomain>
+Stefan Roese <stroese>
+Wolfgang Denk <wdenk>
-- 
2.1.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] scripts: add mailmapper, a tool to create/update mailmap file
  2014-10-15 12:42 [PATCH 0/3] Add .mailmap file and a tool to maintain it Antony Pavlov
  2014-10-15 12:42 ` [PATCH 1/3] add .mailmap for proper git-shortlog output Antony Pavlov
@ 2014-10-15 12:42 ` Antony Pavlov
  2014-10-15 12:42 ` [PATCH 3/3] Update .mailmap using scripts/mailmapper Antony Pavlov
  2 siblings, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2014-10-15 12:42 UTC (permalink / raw)
  To: barebox

From: Masahiro Yamada <yamada.m@jp.panasonic.com>

This tool helps to create/update the mailmap file.

It runs 'git shortlog' internally and searches differently spelled author
names which share the same email address. The author name with the most
commits is asuumed to be a canonical real name. If the number of commits
from the cananonical name is equal to or greater than 'MIN_COMMITS' (=50),
the entry for the cananical name will be output. ('MIN_COMMITS' is used
here because we do not want to create a fat mailmap by adding every author
with only a few commits.)

If there exists a mailmap file specified by the mailmap.file configuration
options or '.mailmap' at the toplevel of the repository, it is used as
a base file.

The base file and the newly added entries are merged together and sorted
alphabetically (but the comment block is kept untouched), and then printed
to standard output.

 Usage
 -----

  scripts/mailmapper

prints the mailmapping to standard output.

  scripts/mailmapper > tmp; mv tmp .mailmap

will be useful for updating '.mailmap' file.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 scripts/mailmapper | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 160 insertions(+)

diff --git a/scripts/mailmapper b/scripts/mailmapper
new file mode 100755
index 0000000..dd1ddf6
--- /dev/null
+++ b/scripts/mailmapper
@@ -0,0 +1,160 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+'''
+A tool to create/update the mailmap file
+
+The command 'git shortlog' summarizes git log output in a format suitable
+for inclusion in release announcements. Each commit will be grouped by
+author and title.
+
+One problem is that the authors' name and/or email address is sometimes
+spelled differently. The .mailmap feature can be used to coalesce together
+commits by the same persion.
+(See 'man git-shortlog' for furthur information of this feature.)
+
+This tool helps to create/update the mailmap file.
+
+It runs 'git shortlog' internally and searches differently spelled author
+names which share the same email address. The author name with the most
+commits is asuumed to be a canonical real name. If the number of commits
+from the cananonical name is equal to or greater than 'MIN_COMMITS',
+the entry for the cananical name will be output. ('MIN_COMMITS' is used
+here because we do not want to create a fat mailmap by adding every author
+with only a few commits.)
+
+If there exists a mailmap file specified by the mailmap.file configuration
+options or '.mailmap' at the toplevel of the repository, it is used as
+a base file. (The mailmap.file configuration takes precedence over the
+'.mailmap' file if both exist.)
+
+The base file and the newly added entries are merged together and sorted
+alphabetically (but the comment block is kept untouched), and then printed
+to standard output.
+
+Usage
+-----
+
+  scripts/mailmapper
+
+prints the mailmapping to standard output.
+
+  scripts/mailmapper > tmp; mv tmp .mailmap
+
+will be useful for updating '.mailmap' file.
+'''
+
+import sys
+import os
+import subprocess
+
+# The entries only for the canonical names with MIN_COMMITS or more commits.
+# This limitation is used so as not to create a too big mailmap file.
+MIN_COMMITS = 50
+
+try:
+    toplevel = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'])
+except subprocess.CalledProcessError:
+    print >> sys.stderr, 'Please run in a git repository.'
+    sys.exit(1)
+
+# strip '\n'
+toplevel = toplevel.rstrip()
+
+# Change the current working directory to the toplevel of the respository
+# for our easier life.
+os.chdir(toplevel)
+
+# First, create 'auther name' vs 'number of commits' database.
+# We assume the name with the most commits as the canonical real name.
+shortlog = subprocess.check_output(['git', 'shortlog', '-s', '-n'])
+
+commits_per_name = {}
+
+for line in shortlog.splitlines():
+    try:
+        commits, name = line.split(None, 1)
+    except ValueError:
+        # ignore lines with an empty author name
+        pass
+    commits_per_name[name] = int(commits)
+
+# Next, coalesce the auther names with the same email address
+shortlog = subprocess.check_output(['git', 'shortlog', '-s', '-n', '-e'])
+
+mail_vs_name = {}
+output = {}
+
+for line in shortlog.splitlines():
+    # tmp, mail = line.rsplit(None, 1) is not safe
+    # because weird email addresses might include whitespaces
+    tmp, mail = line.split('<')
+    mail = '<' + mail.rstrip()
+    try:
+        _, name = tmp.rstrip().split(None, 1)
+    except ValueError:
+        # author name is empty
+        name = ''
+    if mail in mail_vs_name:
+        # another name for the same email address
+        prev_name = mail_vs_name[mail]
+        # Take the name with more commits
+        major_name = sorted([prev_name, name],
+                            key=lambda x: commits_per_name[x] if x else 0)[1]
+        mail_vs_name[mail] = major_name
+        if commits_per_name[major_name] > MIN_COMMITS:
+            output[mail] = major_name
+    else:
+        mail_vs_name[mail] = name
+
+# [1] If there exists a mailmap file at the location pointed to
+#     by the mailmap.file configuration option, update it.
+# [2] If the file .mailmap exists at the toplevel of the repository, update it.
+# [3] Otherwise, create a new mailmap file.
+mailmap_files = []
+
+try:
+    config_mailmap = subprocess.check_output(['git', 'config', 'mailmap.file'])
+except subprocess.CalledProcessError:
+    config_mailmap = ''
+
+config_mailmap = config_mailmap.rstrip()
+if config_mailmap:
+    mailmap_files.append(config_mailmap)
+
+mailmap_files.append('.mailmap')
+
+infile = None
+
+for map_file in mailmap_files:
+    try:
+        infile = open(map_file)
+    except:
+        # Failed to open. Try next.
+        continue
+    break
+
+comment_block = []
+output_lines = []
+
+if infile:
+    for line in infile:
+        if line[0] == '#' or line[0] == '\n':
+            comment_block.append(line)
+        else:
+            output_lines.append(line)
+            break
+    for line in infile:
+        output_lines.append(line)
+    infile.close()
+
+for mail, name in output.items():
+    output_lines.append(name + ' ' + mail + '\n')
+
+output_lines.sort()
+
+sys.stdout.write(''.join(comment_block + output_lines))
-- 
2.1.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] Update .mailmap using scripts/mailmapper
  2014-10-15 12:42 [PATCH 0/3] Add .mailmap file and a tool to maintain it Antony Pavlov
  2014-10-15 12:42 ` [PATCH 1/3] add .mailmap for proper git-shortlog output Antony Pavlov
  2014-10-15 12:42 ` [PATCH 2/3] scripts: add mailmapper, a tool to create/update mailmap file Antony Pavlov
@ 2014-10-15 12:42 ` Antony Pavlov
  2 siblings, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2014-10-15 12:42 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Shiyan, Juergen Beisert

Based on original u-boot commit by Masahiro Yamada:

  commit e89a07e3636d392869d8d00c9399111e65ee2e88
  Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  Date:   Wed Jul 16 17:49:46 2014 +0900

      Update .mailmap using scripts/mailmapper

Add more entries to .mailmap for the canonical names with
50 commits or more.

This commit was generated by the following command:

  scripts/mailmapper > tmp; mv tmp .mailmap

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Alexander Shiyan <shc@milas.spb.ru>
Cc: Eric Bénard <eric@eukrea.com>
Cc: Juergen Beisert <jbe@pengutronix.de>
---
 .mailmap | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.mailmap b/.mailmap
index 8af4375..e8e81a0 100644
--- a/.mailmap
+++ b/.mailmap
@@ -8,6 +8,9 @@
 #  scripts/mailmapper > tmp; mv tmp .mailmap
 #
 
+Alexander Shiyan <shc@milas.spb.ru>
+Eric Bénard <eric@eukrea.com>
+Juergen Beisert <jbe@pengutronix.de>
 Sascha Hauer <sascha@nomad.localdomain>
 Stefan Roese <stroese>
 Wolfgang Denk <wdenk>
-- 
2.1.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-15 12:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-15 12:42 [PATCH 0/3] Add .mailmap file and a tool to maintain it Antony Pavlov
2014-10-15 12:42 ` [PATCH 1/3] add .mailmap for proper git-shortlog output Antony Pavlov
2014-10-15 12:42 ` [PATCH 2/3] scripts: add mailmapper, a tool to create/update mailmap file Antony Pavlov
2014-10-15 12:42 ` [PATCH 3/3] Update .mailmap using scripts/mailmapper Antony Pavlov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox