On 1/10/22 17:14, Martin Liška wrote:
Are you fine with the suggested changes?

Hello.

Jakub had comments so I'm sending v2 where I added few parsing
exceptions. Now it reports:

...
  Chandra Chavva                                        <[email protected]>
  Dehao Chen                                    <[email protected]>
- Fabien Chêne                                  <[email protected]>
  Clément Chigot                                        
<[email protected]>
  Harshit Chopra                                        <[email protected]>
  Tamar Christina                                       
<[email protected]>
  Eric Christopher                              <[email protected]>
+ Fabien Chêne                                  <[email protected]>
  Paul Clarke                                   <[email protected]>
  William Cohen                                 <[email protected]>
  Michael Collison                              <[email protected]>
  Josh Conner                                   <[email protected]>
  R. Kelley Cook                                        <[email protected]>
  Alex Coplan                                   <[email protected]>
  Andrea Corallo                                        <[email protected]>
  Christian Cornelssen                          <[email protected]>
  Ludovic Courtès                                       <[email protected]>
  Lawrence Crowl                                        <[email protected]>
  Ian Dall                                      <[email protected]>
  David Daney                                   <[email protected]>
  Robin Dapp                                    <[email protected]>
  Simon Dardis                                  <[email protected]>
  Sudakshina Das                                        <[email protected]>
  Bud Davis                                     <[email protected]>
  Chris Demetriou                                       <[email protected]>
  Sameera Deshpande                             <[email protected]>
  Wilco Dijkstra                                        <[email protected]>
  Benoit Dupont de Dinechin                     
<[email protected]>
  Jason Eckhardt                                        <[email protected]>
  Bernd Edlinger                                        
<[email protected]>
  Phil Edwards                                  <[email protected]>
  Mark Eggleston                                        
<[email protected]>
  Steve Ellcey                                  <[email protected]>
  Mohan Embar                                   <[email protected]>
  Revital Eres                                  <[email protected]>
  Marc Espie                                    <[email protected]>
  Ansgar Esztermann                             
<[email protected]>
  Doug Evans                                    <[email protected]>
  Chris Fairles                                 <[email protected]>
  Alessandro Fanfarillo                         <[email protected]>
  Changpeng Fang                                        <[email protected]>
  David Faust                                   <[email protected]>
  Li Feng                                               <[email protected]>
  Thomas Fitzsimmons                            <[email protected]>
  Alexander Fomin                                       
<[email protected]>
  Brian Ford                                    <[email protected]>
  John Freeman                                  <[email protected]>
  Nathan Froyd                                  <[email protected]>
  Chao-ying Fu                                  <[email protected]>
  Gary Funck                                    <[email protected]>
  Pompapathi V Gadad                            <[email protected]>
  Eric Gallager                                 <[email protected]>
  Gopalasubramanian Ganesh                      
<[email protected]>
  Kaveh Ghazi                                   <[email protected]>
  Doug Gilmore                                  <[email protected]>
  Matthew Gingell                                       <[email protected]>
  Jan-Benedict Glaw                             <[email protected]>
  Marc Glisse                                   <[email protected]>
  Prachi Godbole                                        
<[email protected]>
  Torbjorn Granlund                             <[email protected]>
  James Greenhalgh                              <[email protected]>
  Doug Gregor                                   <[email protected]>
  Matthew Gretton-Dann                          <[email protected]>
  Yury Gribov                                   <[email protected]>
  Jon Grimm                                     <[email protected]>
  Laurent Guerby                                        <[email protected]>
  Haochen Gui                                   <[email protected]>
  Jiufu Guo                                     <[email protected]>
  Xuepeng Guo                                   <[email protected]>
  Wei Guozhi                                    <[email protected]>
+ Naveen H.S                                    <[email protected]>
  Mostafa Hagog                                 <[email protected]>
  Andrew Haley                                  <[email protected]>
  Frederik Harwath                              <[email protected]>
  Stuart Hastings                                       <[email protected]>
  Michael Haubenwallner                         
<[email protected]>
  Pat Haugen                                    <[email protected]>
  Michael Hayes                                 <[email protected]>
  Alan Hayward                                  <[email protected]>
  Li Jia He                                     <[email protected]>
  Mark Heffernan                                        <[email protected]>
  George Helffrich                              <[email protected]>
  Daniel Hellstrom                              <[email protected]>
  Fergus Henderson                              <[email protected]>
  Stuart Henderson                              <[email protected]>
  Marius Hillenbrand                            <[email protected]>
  Matthew Hiller                                        <[email protected]>
  Kazu Hirata                                   <[email protected]>
  Manfred Hollstein                             <[email protected]>
  Cong Hou                                      <[email protected]>
  Falk Hueffner                                 <[email protected]>
  Andrew John Hughes                            <[email protected]>
  Dominique d'Humieres                          <[email protected]>
  Andy Hutchinson                                       <[email protected]>
  Joel Hutton                                   <[email protected]>
  Lewis Hyatt                                   <[email protected]>
- Naveen H.S                                    <[email protected]>
  Roland Illig                                  <[email protected]>
  Meador Inge                                   <[email protected]>
  Bernardo Innocenti                            <[email protected]>
  Mihail Ionescu                                        <[email protected]>
  Vladislav Ivanishin                           <[email protected]>
  Alexander Ivchenko                            <[email protected]>
  Balaji V. Iyer                                        <[email protected]>
- Pekka Jääskeläinen                            
<[email protected]>
  Daniel Jacobowitz                             <[email protected]>
  Andreas Jaeger                                        <[email protected]>
  Harsha Jagasia                                        <[email protected]>
  Fariborz Jahanian                             <[email protected]>
  Qian Jianhua                                  <[email protected]>
  Janis Johnson                                 <[email protected]>
  Teresa Johnson                                        <[email protected]>
  Kean Johnston                                 <[email protected]>
  Phillip Jordan                                        
<[email protected]>
  Tim Josling                                   <[email protected]>
+ Pekka Jääskeläinen                            
<[email protected]>
  Victor Kaplansky                              <[email protected]>
  Geoffrey Keating                              <[email protected]>
  Brendan Kehoe                                 <[email protected]>
  Andi Kleen                                    <[email protected]>
  Matthias Klose                                        <[email protected]>
  Jeff Knaggs                                   <[email protected]>
  Michael Koch                                  <[email protected]>
  Nicolas Koenig                                        
<[email protected]>
  Boris Kolpackov                                       
<[email protected]>
  Dave Korn                                     <[email protected]>
  Julia Koval                                   <[email protected]>
  Matt Kraai                                    <[email protected]>
  Jan Kratochvil                                        
<[email protected]>
  Matthias Kretz                                        <[email protected]>
  Louis Krupp                                   <[email protected]>
  Prathamesh Kulkarni                           <[email protected]>
  Venkataramanan Kumar                          <[email protected]>
  Doug Kwan                                     <[email protected]>
  Scott Robert Ladd                             <[email protected]>
  Razya Ladelsky                                        <[email protected]>
  Thierry Lafage                                        
<[email protected]>
+ Aaron W. LaFramboise                          <[email protected]>
  Rask Ingemann Lambertsen                      <[email protected]>
  Jerome Lambourg                                       <[email protected]>
- Aaron W. LaFramboise                          <[email protected]>
  Asher Langton                                 <[email protected]>
  Chris Lattner                                 <[email protected]>
  Terry Laurenzo                                        <[email protected]>
  Alan Lawrence                                 <[email protected]>
  Jozef Lawrynowicz                             <[email protected]>
  Georg-Johann Lay                              <[email protected]>
  Vlad Lazar                                    <[email protected]>
  Marc Lehmann                                  <[email protected]>
  James Lemke                                   <[email protected]>
  Ilya Leoshkevich                              <[email protected]>
  Kriang Lerdsuwanakij                          <[email protected]>
  Renlin Li                                     <[email protected]>
  Xinliang David Li                             <[email protected]>
  Kewen Lin                                     <[email protected]>
  Chen Liqin                                    <[email protected]>
  Jiangning Liu                                 <[email protected]>
  Sa Liu                                                <[email protected]>
  Ralph Loader                                  <[email protected]>
  Sheldon Lobo                                  <[email protected]
  Gabor Loki                                    <[email protected]>
- Manuel López-Ibáñez                           <[email protected]>
  Carl Love                                     <[email protected]>
- Martin v. Löwis                                       
<[email protected]>
  H.J. Lu                                               <[email protected]>
  Xiong Hu Luo                                  <[email protected]>
  Bin Bin Lv                                    <[email protected]>
  Christophe Lyon                                       <[email protected]>
+ Manuel López-Ibáñez                           <[email protected]>
+ Martin v. Löwis                                       
<[email protected]>
  Jun Ma                                                
<[email protected]>
  Luis Machado                                  <[email protected]>
...

Are you fine with that?

Thanks,
Martin
From c1a2be909f550b0a820bfd0ae857cf667faba2d1 Mon Sep 17 00:00:00 2001
From: Martin Liska <[email protected]>
Date: Mon, 10 Jan 2022 16:49:31 +0100
Subject: [PATCH] Check sorting of MAINTAINERS.

contrib/ChangeLog:

	* check-MAINTAINERS.py: New file.
---
 contrib/check-MAINTAINERS.py | 110 +++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100755 contrib/check-MAINTAINERS.py

diff --git a/contrib/check-MAINTAINERS.py b/contrib/check-MAINTAINERS.py
new file mode 100755
index 00000000000..860b8ca95e8
--- /dev/null
+++ b/contrib/check-MAINTAINERS.py
@@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING.  If not, write to
+# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Check that names in the file are sorted
+# alphabetically by surname.
+
+import locale
+import sys
+from difflib import ndiff
+from itertools import dropwhile, takewhile
+
+locale.setlocale(locale.LC_ALL, 'en_US.utf8')
+
+exit_code = 0
+
+if len(sys.argv) != 2:
+    print('Usage: ./check-MAINTAINERS.py path-to/MAINTAINERS')
+    sys.exit(1)
+
+
+def sort_by_surname(line):
+    name = line.split('\t')[0]
+    parts = name.split()
+    surname = parts[-1]
+
+    # Special-case some names
+    if name == 'Stefan Schulze Frielinghaus':
+        surname = parts[1]
+    elif name == 'Kris Van Hees':
+        surname = parts[1]
+    elif surname == "d'Humieres":
+        surname = 'Humieres'
+
+    return (surname, line)
+
+
+def has_tab(line):
+    return '\t' in line
+
+
+def is_empty(line):
+    return line
+
+
+def check_group(name, lines):
+    global exit_code
+
+    for line in lines:
+        if line.startswith(' '):
+            print(f'Line should not start with space: "{line}"')
+            exit_code = 2
+
+    lines = [line + '\n' for line in lines]
+    sorted_lines = sorted(lines, key=sort_by_surname)
+    if lines != sorted_lines:
+        exit_code = 1
+        diff = ndiff(lines, sorted_lines)
+        print(f'Wrong order for {name}:\n')
+        print(''.join(diff))
+    else:
+        print(f'{name} are fine!')
+
+
+lines = open('MAINTAINERS').read().splitlines()
+
+needle = 'Global Reviewers'
+lines = list(dropwhile(lambda x: x.strip() != needle, lines))
+lines = lines[2:]
+
+chunk = list(takewhile(is_empty, lines))
+check_group(needle, chunk)
+
+needle = 'Write After Approval'
+lines = list(dropwhile(lambda x: needle not in x, lines))
+lines = lines[2:]
+
+chunk = list(takewhile(is_empty, lines))
+check_group(needle, chunk)
+
+needle = 'Bug database only accounts'
+lines = list(dropwhile(lambda x: needle not in x, lines))
+lines = lines[2:]
+
+chunk = list(takewhile(is_empty, lines))
+check_group(needle, chunk)
+
+needle = 'Contributing under the DCO'
+lines = list(dropwhile(lambda x: needle not in x, lines))[1:]
+lines = list(dropwhile(lambda x: not has_tab(x), lines))
+check_group(needle, lines)
+
+sys.exit(exit_code)
-- 
2.34.1

Reply via email to