From 4794f18bf4689746dd4e9f2d34d7d8d0f0cff184 Mon Sep 17 00:00:00 2001 From: Quentin Monnet Date: Thu, 25 Apr 2024 23:21:09 +0100 Subject: [PATCH] sync: Sync .mailmap entries The kernel repository has a .mailmap file to remap author names and email addresses to their desired format in Git logs (for details, see gitmailmap documentation [0]). Alas, this is only visible for author information when looking at the logs locally, as GitHub does not support mailmaps at the moment [1]. This commit adds a .mailmap file for libbpf, automatically generated from the kernel's version. The script to generate the .mailmap is added, too: it works by grepping email addresses from authors in the repository, and collecting all lines ending with this address in the kernel's .mailmap - in other words, all lines where this address is used as a pattern for a remapping. To keep the .mailmap up-to-date, add a call to the script to sync-kernel.sh. [0] https://git-scm.com/docs/gitmailmap [1] https://github.com/orgs/community/discussions/22518 Signed-off-by: Quentin Monnet --- .mailmap | 16 ++++++++++++++++ scripts/mailmap-update.sh | 37 +++++++++++++++++++++++++++++++++++++ scripts/sync-kernel.sh | 6 ++++++ 3 files changed, 59 insertions(+) create mode 100644 .mailmap create mode 100755 scripts/mailmap-update.sh diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..9f8196f --- /dev/null +++ b/.mailmap @@ -0,0 +1,16 @@ +Alexei Starovoitov +Antoine Tenart +Björn Töpel +Changbin Du +Colin Ian King +Dan Carpenter +Geliang Tang +Herbert Xu +Jakub Kicinski +Leo Yan +Mark Starovoytov +Maxim Mikityanskiy +Maxim Mikityanskiy +Quentin Monnet +Quentin Monnet +Vadim Fedorenko diff --git a/scripts/mailmap-update.sh b/scripts/mailmap-update.sh new file mode 100755 index 0000000..13a3dcf --- /dev/null +++ b/scripts/mailmap-update.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -eu + +usage () { + echo "USAGE: ./mailmap-update.sh " + exit 1 +} + +LIBBPF_REPO="${1-""}" +LINUX_REPO="${2-""}" + +if [ -z "${LIBBPF_REPO}" ] || [ -z "${LINUX_REPO}" ]; then + echo "Error: libbpf or linux repos are not specified" + usage +fi + +LIBBPF_MAILMAP="${LIBBPF_REPO}/.mailmap" +LINUX_MAILMAP="${LINUX_REPO}/.mailmap" + +tmpfile="$(mktemp)" +cleanup() { + rm -f "${tmpfile}" +} +trap cleanup EXIT + +grep_lines() { + local pattern="$1" + local file="$2" + grep "${pattern}" "${file}" || true +} + +while read -r email; do + grep_lines "${email}$" "${LINUX_MAILMAP}" >> "${tmpfile}" +done < <(git log --format='<%ae>' | sort -u) + +sort -u "${tmpfile}" > "${LIBBPF_MAILMAP}" diff --git a/scripts/sync-kernel.sh b/scripts/sync-kernel.sh index 55ffcd1..36bb96f 100755 --- a/scripts/sync-kernel.sh +++ b/scripts/sync-kernel.sh @@ -352,4 +352,10 @@ else esac fi +echo "Regenerating .mailmap..." +cd_to "${LINUX_REPO}" +git checkout "${TIP_SYM_REF}" +cd_to "${LIBBPF_REPO}" +"${LIBBPF_REPO}"/scripts/mailmap-update.sh "${LIBBPF_REPO}" "${LINUX_REPO}" + cleanup