This is an automated email from the ASF dual-hosted git repository.

jhyde pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 343132ecc98779e55fbaf5c75d3d9e349dd6a8c7
Author: Julian Hyde <[email protected]>
AuthorDate: Fri Nov 17 11:00:12 2023 -0800

    [CALCITE-6125] Automate generation of contributor names in release notes by 
adding a git mailmap file
    
    Add entries to .mailmap to that release notes since 1.29
    would be generated correctly.
    
    Update HOWTO examples showing how to generate release notes.
    
    Add a lint test to ensure that .mailmap remains sorted.
    
    Close apache/calcite#3533
---
 .mailmap                                           | 148 +++++++++++++++++++++
 .../java/org/apache/calcite/test/LintTest.java     |  34 +++++
 .../java/org/apache/calcite/util/TestUnsafe.java   |   3 +-
 site/_docs/howto.md                                |  13 +-
 4 files changed, 191 insertions(+), 7 deletions(-)

diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000000..82ec920401
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,148 @@
+# Git mail map; see 'git help mailmap' for details.
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+Abhishek Dasgupta <[email protected]>
+Adam Kennedy <[email protected]>
+Alan Jin <[email protected]>
+Ali Mansour <[email protected]>
+Amir Gajst <[email protected]>
+Botong Huang <[email protected]>
+Cancai Cai <[email protected]>
+Charbel Yazbeck <[email protected]>
+Chen Kai <[email protected]>
+Chunhui Shi <[email protected]>
+Chunwei Lei <[email protected]>
+Chunwei Lei <[email protected]>
+Chunwei Lei <[email protected]>
+Daniel Henneberger <[email protected]>
+Daniel Henneberger <[email protected]>
+Danny Chan <[email protected]>
+Danny Chan <[email protected]>
+Darion Yaphet <[email protected]>
+David Handermann <[email protected]>
+Dhirenda Gautam <[email protected]>
+Divyanshu Srivastava <[email protected]>
+Dmitry Sysolyatin <[email protected]>
+Dmitry Sysolyatin <[email protected]>
+Drew Schmitt <[email protected]>
+Dylan Adams <[email protected]>
+Evgeniy Stanilovskiy <[email protected]> # aka Eugen Stan, Evgeny 
Stanilovsky
+Evgeniy Stanilovskiy <[email protected]>
+Feng Guo <[email protected]>
+Feng Zhu <[email protected]> # DonnyZone at github
+Feng Zhu <[email protected]>
+Feng Zhu <[email protected]>
+Feng Zhu <[email protected]>
+Godfrey He <[email protected]>
+Hequn Cheng <[email protected]>
+Hong Shen (沈洪) <[email protected]>
+Hongyu Guo <[email protected]>
+Hongze Zhang <[email protected]>
+Hsuan-Yi Chu <[email protected]>
+Ian Bertolacci <[email protected]>
+Jacky Lau <[email protected]> # aka Yong Liu
+Jacky Lau <[email protected]>
+Jacky Woo <[email protected]>
+Jacky Yin <[email protected]>
+James Kim <[email protected]>
+Janhui Dong <[email protected]>
+Jark Wu (云邪) <[email protected]>
+Jasmin Trada <[email protected]>
+Jay Narale <[email protected]>
+Jeffery Zhang (张俭) <[email protected]>
+Jerin John <[email protected]>
+Jiajun Xie <[email protected]> # aka Jake Xie, Jiajin Bernoulli
+Jiasen Sheng <[email protected]>
+Jin Xing <[email protected]>
+Jin Xing <[email protected]> # aka jx158167
+Joey Moore <[email protected]>
+Johannes Schulte <[email protected]>
+Julian Feinauer <[email protected]>
+Julian Hyde <[email protected]>
+Julian Hyde <[email protected]>
+Julian Hyde <[email protected]>
+Julian Hyde <[email protected]>
+Kevin Liew <[email protected]>
+Kevin Liew <[email protected]>
+Khawla Mouhoubi <[email protected]>
+Konstantin Orlov <[email protected]>
+Krisztian Kasa <[email protected]>
+Lei Shen <[email protected]>
+LeoWangLZ <[email protected]> # aka Rheet Wong?
+Liao Xintao <[email protected]>
+Lincoln Lee <[email protected]>
+Liya Fan <[email protected]>
+Louis Kang <[email protected]> # aka LM Kang
+Maryann Xue <[email protected]>
+Maryann Xue <[email protected]>
+Min Dai <[email protected]>
+Mingcan Wang <[email protected]>
+Mou Wu <[email protected]>
+Mou Wu <[email protected]>
+Nick Riasanovsky <[email protected]> # aka Nicholas J Riasanovsky
+Nishant Bangarwa <[email protected]>
+Pavel Gubin <[email protected]>
+Pawel Ruchaj <[email protected]>
+Peng Wang <[email protected]>
+pengzhiwei <[email protected]>
+Praveen Kumar <[email protected]>
+Qi Yu (余启) <[email protected]>
+Qianjin Xu <[email protected]>
+Rafay Qureshi <[email protected]>
+Ruben Quesada Lopez <[email protected]>
+Rui Wang <[email protected]>
+Runkang He (何润康) <[email protected]>
+Runkang He (何润康) <[email protected]>
+Sandeep Chada <[email protected]>
+Sergei Tsvetkov <[email protected]>
+Sergey Nuyanzin <[email protected]>
+Shikha Somani <[email protected]>
+Shradha Ambekar <[email protected]>
+Shuming Li <[email protected]>
+Shuo Cheng <[email protected]>
+Slim Bouguerra <[email protected]>
+Stamatis Zampetakis <[email protected]>
+Stamatis Zampetakis <[email protected]>
+Taras Ledkov <[email protected]>
+Ted Xu (少杰) <[email protected]>
+Venki Korukanti <[email protected]>
+Venki Korukanti <[email protected]>
+Vladimir Ozerov <[email protected]>
+Vova Vysotskyi <[email protected]>
+Wang Yanlin <[email protected]>
+Wang Yanlin <[email protected]>
+Weijie Wu <[email protected]>
+Wenhui Tang <[email protected]>
+Wenrui Meng <[email protected]>
+Xiaogang Zhou <[email protected]>
+Xiong Duan <[email protected]>
+Xu ZhaoHui <[email protected]> # aka dz, xzh
+Xurenhe <[email protected]> # aka wojustme
+Yanjing Wang <[email protected]>
+Yeong Wei <[email protected]>
+Yingyu Wang <[email protected]>
+Yingyu Wang <[email protected]>
+Yiqun Zhang <[email protected]>
+Zhe Hu <[email protected]>
+Zhen Wang <[email protected]>
+Zhen Wang <[email protected]>
+Zhengqiang Duan <[email protected]>
+Zhiqiang He <[email protected]>
+Zhiqiang He <[email protected]>
+Zhong Yu <[email protected]>
+Zou Dan <[email protected]>
+Zuozhi Wang <[email protected]>
diff --git a/core/src/test/java/org/apache/calcite/test/LintTest.java 
b/core/src/test/java/org/apache/calcite/test/LintTest.java
index 01e283efb5..a0ceb69e3e 100644
--- a/core/src/test/java/org/apache/calcite/test/LintTest.java
+++ b/core/src/test/java/org/apache/calcite/test/LintTest.java
@@ -32,6 +32,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
 import org.checkerframework.checker.nullness.qual.Nullable;
 import org.junit.jupiter.api.Test;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -408,6 +409,39 @@ class LintTest {
     }
   }
 
+  /** Ensures that the {@code .mailmap} file is sorted. */
+  @Test void testMailmapFile() {
+    final List<File> files = TestUnsafe.getTextFiles();
+    final File contributorsFile =
+        getOnlyElement(
+            filter(files, f -> f.getName().equals(".mailmap")));
+    final List<String> lines = new ArrayList<>();
+    forEachLineIn(contributorsFile, line -> {
+      if (!line.startsWith("#")) {
+        lines.add(line);
+      }
+    });
+    String line = firstOutOfOrder(lines, String.CASE_INSENSITIVE_ORDER);
+    if (line != null) {
+      fail("line '" + line + "' is out of order");
+    }
+  }
+
+  /** Performs an action for each line in a file. */
+  private static void forEachLineIn(File file, Consumer<String> consumer) {
+    try (BufferedReader r = Util.reader(file)) {
+      for (;;) {
+        String line = r.readLine();
+        if (line == null) {
+          break;
+        }
+        consumer.accept(line);
+      }
+    } catch (IOException e) {
+      throw Util.throwAsRuntime(e);
+    }
+  }
+
   /** Returns the first element in a list that is out of order, or null if the
    * list is sorted. */
   private static <E> @Nullable E firstOutOfOrder(Iterable<E> elements,
diff --git a/core/src/test/java/org/apache/calcite/util/TestUnsafe.java 
b/core/src/test/java/org/apache/calcite/util/TestUnsafe.java
index e9e24118c0..71b4d83d5a 100644
--- a/core/src/test/java/org/apache/calcite/util/TestUnsafe.java
+++ b/core/src/test/java/org/apache/calcite/util/TestUnsafe.java
@@ -156,7 +156,8 @@ public abstract class TestUnsafe {
   /** Returns a list of text files in git. */
   public static List<File> getTextFiles() {
     return getGitFiles("*.bat", "*.cmd", "*.csv", "*.fmpp", "*.ftl",
-        "*.iq", "*.java", "*.json", "*.jj", "*.kt", "*.kts", "*.md",
+        "*.iq", "*.java", "*.json", "*.jj",
+        "*.kt", "*.kts", ".mailmap", "*.md",
         "*.properties", "*.sh", "*.sql", "*.txt", "*.xml", "*.yaml",
         "*.yml");
   }
diff --git a/site/_docs/howto.md b/site/_docs/howto.md
index fcb0b68241..50bce36a2f 100644
--- a/site/_docs/howto.md
+++ b/site/_docs/howto.md
@@ -756,15 +756,16 @@ Before you start:
   a fix version assigned (most likely the version we are
   just about to release)
 
-Generate a list of contributors by running the following (changing the
-date literal to the date of the previous release):
+Generate a list of contributors:
 ```
+# Commits since 1.35
+range=calcite-1.35.0..HEAD
 # distinct authors
-./sqlsh "select distinct author from git_commits where author_timestamp > DATE 
'2021-06-03' order by 1"
+git log --abbrev-commit --pretty=format:'%aN,' $range | sort -u
 # most prolific authors
-./sqlsh "select author, count(*) from git_commits where commit_timestamp > 
DATE '2021-06-03' group by author order by 2"
-# number of commits, distinct authors, and JIRA cases
-./sqlsh "select count(*) as c, count(distinct author) as a, count(*) filter 
(where message like '%CALCITE-%') as j from git_commits where commit_timestamp 
> DATE '2021-06-03' order by 1"
+git log --abbrev-commit --pretty=format:'%aN' $range | sort | uniq -c | sort 
-nr
+# number of JIRA cases
+git log --abbrev-commit --pretty=format:'%f' $range | awk -F- '$1 == "CALCITE" 
{print $2}' | sort -u | wc
 ```
 
 Smoke-test `sqlline` with Spatial and Oracle function tables:

Reply via email to