From 343132ecc98779e55fbaf5c75d3d9e349dd6a8c7 Mon Sep 17 00:00:00 2001 From: Julian Hyde Date: Fri, 17 Nov 2023 11:00:12 -0800 Subject: [PATCH] [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 ++++++++++++++++++ .../org/apache/calcite/test/LintTest.java | 34 ++++ .../org/apache/calcite/util/TestUnsafe.java | 3 +- site/_docs/howto.md | 13 +- 4 files changed, 191 insertions(+), 7 deletions(-) create mode 100644 .mailmap diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000000..82ec920401d --- /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 +Adam Kennedy +Alan Jin +Ali Mansour +Amir Gajst +Botong Huang +Cancai Cai <77189278+caicancai@users.noreply.github.com> +Charbel Yazbeck +Chen Kai +Chunhui Shi +Chunwei Lei +Chunwei Lei +Chunwei Lei +Daniel Henneberger +Daniel Henneberger +Danny Chan +Danny Chan +Darion Yaphet +David Handermann +Dhirenda Gautam +Divyanshu Srivastava +Dmitry Sysolyatin +Dmitry Sysolyatin +Drew Schmitt +Dylan Adams +Evgeniy Stanilovskiy # aka Eugen Stan, Evgeny Stanilovsky +Evgeniy Stanilovskiy +Feng Guo +Feng Zhu # DonnyZone at github +Feng Zhu +Feng Zhu +Feng Zhu +Godfrey He +Hequn Cheng +Hong Shen (沈洪) +Hongyu Guo +Hongze Zhang +Hsuan-Yi Chu +Ian Bertolacci +Jacky Lau # aka Yong Liu +Jacky Lau +Jacky Woo +Jacky Yin +James Kim +Janhui Dong +Jark Wu (云邪) +Jasmin Trada +Jay Narale +Jeffery Zhang (张俭) +Jerin John +Jiajun Xie # aka Jake Xie, Jiajin Bernoulli +Jiasen Sheng +Jin Xing +Jin Xing # aka jx158167 +Joey Moore +Johannes Schulte +Julian Feinauer +Julian Hyde +Julian Hyde +Julian Hyde +Julian Hyde +Kevin Liew +Kevin Liew +Khawla Mouhoubi +Konstantin Orlov +Krisztian Kasa +Lei Shen +LeoWangLZ # aka Rheet Wong? +Liao Xintao +Lincoln Lee +Liya Fan +Louis Kang # aka LM Kang +Maryann Xue +Maryann Xue +Min Dai +Mingcan Wang +Mou Wu +Mou Wu +Nick Riasanovsky # aka Nicholas J Riasanovsky +Nishant Bangarwa +Pavel Gubin +Pawel Ruchaj +Peng Wang +pengzhiwei +Praveen Kumar +Qi Yu (余启) +Qianjin Xu +Rafay Qureshi +Ruben Quesada Lopez +Rui Wang +Runkang He (何润康) +Runkang He (何润康) +Sandeep Chada <44845836+chadasa@users.noreply.github.com> +Sergei Tsvetkov <9326077@gmail.com> +Sergey Nuyanzin +Shikha Somani +Shradha Ambekar +Shuming Li +Shuo Cheng +Slim Bouguerra +Stamatis Zampetakis <15013153+zabetak@users.noreply.github.com> +Stamatis Zampetakis +Taras Ledkov +Ted Xu (少杰) +Venki Korukanti +Venki Korukanti +Vladimir Ozerov +Vova Vysotskyi +Wang Yanlin <1989yanlinwang@163.com> +Wang Yanlin +Weijie Wu +Wenhui Tang +Wenrui Meng +Xiaogang Zhou +Xiong Duan +Xu ZhaoHui <953396112@qq.com> # aka dz, xzh +Xurenhe # aka wojustme +Yanjing Wang +Yeong Wei +Yingyu Wang +Yingyu Wang +Yiqun Zhang +Zhe Hu +Zhen Wang +Zhen Wang +Zhengqiang Duan +Zhiqiang He +Zhiqiang He +Zhong Yu +Zou Dan +Zuozhi Wang 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 01e283efb51..a0ceb69e3ee 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 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 @@ private static void checkMessage(String subject, String body, } } + /** Ensures that the {@code .mailmap} file is sorted. */ + @Test void testMailmapFile() { + final List files = TestUnsafe.getTextFiles(); + final File contributorsFile = + getOnlyElement( + filter(files, f -> f.getName().equals(".mailmap"))); + final List 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 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 @Nullable E firstOutOfOrder(Iterable 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 e9e24118c08..71b4d83d5a6 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 static List getJavaFiles() { /** Returns a list of text files in git. */ public static List 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 fcb0b682412..50bce36a2f8 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: