From 4be2c3acd51fe2785be278b59195def0dbd8834e Mon Sep 17 00:00:00 2001 From: Dennis Gosnell Date: Mon, 30 Jan 2023 08:27:03 +0900 Subject: [PATCH] haskellPackages: ignore maintainers without email The Haskell Hydra report generator (`maintainers/scripts/haskell/hydra-report.hs`) uses this `maintainer-handles.nix` script for generating a mapping of email addresses to GitHub handles. This `maintainer-handles.nix` script is necessary because the Haskell Hydra report generator gets Hydra job status info as input, but needs to ping users on GitHub. Hydra job status info only contains user emails (not GitHub handles). So the `maintainer-handles.nix` script is necessary for looking up GitHub handles from email addresses. This commit fixes the `maintainers-handles.nix` code to ignore maintainers that don't have email addresses. The code was originally assuming that all maintainers have email addresses, but there was recently a maintainer added without an email address. --- .../scripts/haskell/maintainer-handles.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/maintainers/scripts/haskell/maintainer-handles.nix b/maintainers/scripts/haskell/maintainer-handles.nix index 08c6bc4c96af..d650e82f8b0c 100644 --- a/maintainers/scripts/haskell/maintainer-handles.nix +++ b/maintainers/scripts/haskell/maintainer-handles.nix @@ -1,7 +1,21 @@ # Nix script to lookup maintainer github handles from their email address. Used by ./hydra-report.hs. +# +# This script produces an attr set mapping of email addresses to GitHub handles: +# +# ```nix +# > import ./maintainer-handles.nix +# { "cdep.illabout@gmail.com" = "cdepillabout"; "john@smith.com" = "johnsmith"; ... } +# ``` +# +# This mapping contains all maintainers in ../../mainatainer-list.nix, but it +# ignores maintainers who don't have a GitHub account or an email address. let pkgs = import ../../.. {}; maintainers = import ../../maintainer-list.nix; inherit (pkgs) lib; - mkMailGithubPair = _: maintainer: if maintainer ? github then { "${maintainer.email}" = maintainer.github; } else {}; + mkMailGithubPair = _: maintainer: + if (maintainer ? email) && (maintainer ? github) then + { "${maintainer.email}" = maintainer.github; } + else + {}; in lib.zipAttrsWith (_: builtins.head) (lib.mapAttrsToList mkMailGithubPair maintainers)