The script is capable of checking if MAINTAINER names are sorted alphabetically. I used English locales and the scripts emits:
Are you fine with the suggested changes? Cheers, Martin $ contrib/check-MAINTAINERS.py MAINTAINERS Global Reviewers are fine! Wrong order for Write After Approval: Mark G. Adams <[email protected]> Pedro Alves <[email protected]> Raksit Ashok <[email protected]> Matt Austern <[email protected]> David Ayers <[email protected]> Prakhar Bahuguna <[email protected]> Giovanni Bajo <[email protected]> Simon Baldwin <[email protected]> Scott Bambrough <[email protected]> Wolfgang Bangerth <[email protected]> Gergö Barany <[email protected]> Charles Baylis <[email protected]> Tejas Belagod <[email protected]> Matthew Beliveau <[email protected]> Serge Belyshev <[email protected]> Jon Beniston <[email protected]> Andrew Bennett <[email protected]> Andrew Benson <[email protected]> Daniel Berlin <[email protected]> Pat Bernardi <[email protected]> Jan Beulich <[email protected]> Indu Bhagat <[email protected]> David Billinghurst <[email protected]> Tomas Bily <[email protected]> Laurynas Biveinis <[email protected]> Eric Blake <[email protected]> Phil Blundell <[email protected]> Hans Boehm <[email protected]> Lynn Boger <[email protected]> Ian Bolton <[email protected]> Andrea Bona <[email protected]> Neil Booth <[email protected]> Antoni Boucher <[email protected]> Robert Bowdidge <[email protected]> Joel Brobecker <[email protected]> Dave Brolley <[email protected]> Christian Bruel <[email protected]> Kevin Buettner <[email protected]> Andrew Burgess <[email protected]> Adam Butcher <[email protected]> Andrew Cagney <[email protected]> Daniel Carrera <[email protected]> Stephane Carrez <[email protected]> Gabriel Charette <[email protected]> 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]> + Stefan Schulze Frielinghaus <[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]> + Kris Van Hees <[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]> + Aaron W. LaFramboise <[email protected]> Scott Robert Ladd <[email protected]> Razya Ladelsky <[email protected]> Thierry Lafage <[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]> Ziga Mahkovec <[email protected]> Matthew Malcomson <[email protected]> Mikhail Maltsev <[email protected]> Stamatis Markianos-Wright <[email protected]> Patrick Marlier <[email protected]> Simon Martin <[email protected]> Alejandro Martinez <[email protected]> Ranjit Mathew <[email protected]> Paulo Matos <[email protected]> Michael Matz <[email protected]> Greg McGary <[email protected]> Roland McGrath <[email protected]> Bryce McKinlay <[email protected]> Adam Megacz <[email protected]> Bingfeng Mei <[email protected]> Jim Meyering <[email protected]> Martin Michlmayr <[email protected]> Lee Millward <[email protected]> Dragan Mladjenovic <[email protected]> Alan Modra <[email protected]> Catherine Moore <[email protected]> James A. Morrison <[email protected]> Brooks Moses <[email protected]> Dirk Mueller <[email protected]> Phil Muldoon <[email protected]> Gaius Mulley <[email protected]> Steven Munroe <[email protected]> Szabolcs Nagy <[email protected]> Quentin Neill <[email protected]> Adam Nemet <[email protected]> Thomas Neumann <[email protected]> Dan Nicolaescu <[email protected]> Kelvin Nilsen <[email protected]> James Norris Diego Novillo <[email protected]> Dorit Nuzman <[email protected]> David O'Brien <[email protected]> Carlos O'Donell <[email protected]> Peter O'Gorman <[email protected]> Braden Obrzut <[email protected]> Andrea Ornstein <[email protected]> Maxim Ostapenko <[email protected]> Patrick Palka <[email protected]> Srinath Parvathaneni <[email protected]> Devang Patel <[email protected]> Andris Pavenis <[email protected]> Fernando Pereira <[email protected]> Sebastian Perta <[email protected]> Sebastian Peryt <[email protected]> Johannes Pfau <[email protected]> Kaushik Phatak <[email protected]> Nicolas Pitre <[email protected]> Michael Ploujnikov <[email protected]> Paul Pluzhnikov <[email protected]> Antoniu Pop <[email protected]> Marc Poulhiès <[email protected]> Siddhesh Poyarekar <[email protected]> Vidya Praveen <[email protected]> Thomas Preud'homme <[email protected]> Vladimir Prus <[email protected]> Hafiz Abid Qadeer <[email protected]> Yao Qi <[email protected]> Jerry Quinn <[email protected]> Navid Rahimi <[email protected]> Easwaran Raman <[email protected]> Joe Ramsay <[email protected]> Rolf Rasmussen <[email protected]> Fritz Reese <[email protected]> Volker Reichelt <[email protected]> Bernhard Reutner-Fischer <[email protected]> Tom Rix <[email protected]> Thomas Rodgers <[email protected]> Craig Rodrigues <[email protected]> Erven Rohou <[email protected]> Ira Rosen <[email protected]> Yvan Roux <[email protected]> Eugene Rozenfeld <[email protected]> Silvius Rus <[email protected]> Matthew Sachs <[email protected]> Ankur Saini <[email protected]> Hariharan Sandanagobalane <[email protected]> Duncan Sands <[email protected]> Sujoy Saraswati <[email protected]> Trevor Saunders <[email protected]> Aaron Sawdey <[email protected]> Roger Sayle <[email protected]> Will Schmidt <[email protected]> - Stefan Schulze Frielinghaus <[email protected]> Tilo Schwarz <[email protected]> Martin Sebor <[email protected]> Svein Seldal <[email protected]> Senthil Kumar Selvaraj <[email protected]> Thiemo Seufer <[email protected]> Bill Seurer <[email protected]> Tim Shen <[email protected]> David Sherwood <[email protected]> Sharad Singhai <[email protected]> Johannes Singler <[email protected]> Franz Sirl <[email protected]> Jan Sjodin <[email protected]> Trevor Smigiel <[email protected]> Edward Smith-Rowland <[email protected]> Anatoly Sokolov <[email protected]> Michael Sokolov <[email protected]> Jayant Sonar <[email protected]> Richard Stallman <[email protected]> Basile Starynkevitch <[email protected]> Jakub Staszak <[email protected]> Graham Stott <[email protected]> Jeff Sturm <[email protected]> YunQiang Su <[email protected]> Robert Suchanek <[email protected]> Andrew Sutton <[email protected]> Gabriele Svelto <[email protected]> Toma Tabacu <[email protected]> Omar Tahir <[email protected]> Sriraman Tallam <[email protected]> Samuel Tardieu <[email protected]> Sam Tebbs <[email protected]> Dinar Temirbulatov <[email protected]> Kresten Krab Thorup <[email protected]> Kai Tietz <[email protected]> Ilya Tocar <[email protected]> Petter Tomner <[email protected]> Philipp Tomsich <[email protected]> Daniel Towner <[email protected]> Konrad Trifunovic <[email protected]> Markus Trippelsdorf <[email protected]> Sergei Trofimovich <[email protected]> Igor Tsimbalist <[email protected]> Martin Uecker <[email protected]> David Ung <[email protected]> Neil Vachharajani <[email protected]> - Kris Van Hees <[email protected]> Joost VandeVondele <[email protected]> Andre Vehreschild <[email protected]> Alex Velenko <[email protected]> Ilya Verbin <[email protected]> Andre Vieira <[email protected]> Rasmus Villemoes <[email protected]> Kugan Vivekanandarajah <[email protected]> Marcel Vollweiler <[email protected]> Ville Voutilainen <[email protected]> Nenad Vukicevic <[email protected]> Feng Wang <[email protected]> Hongyu Wang <[email protected]> Jiong Wang <[email protected]> Stephen M. Webb <[email protected]> John Wehle <[email protected]> Florian Weimer <[email protected]> Zack Weinberg <[email protected]> Mark Wielaard <[email protected]> Edmar Wienskoski <[email protected]> Ollie Wild <[email protected]> Kevin Williams <[email protected]> Przemyslaw Wirkus <[email protected]> Carlo Wood <[email protected]> Jackson Woodruff <[email protected]> Jonathan Wright <[email protected]> Ruoyao Xi <[email protected]> Mingjie Xing <[email protected]> Chenghua Xu <[email protected]> Canqun Yang <[email protected]> Fei Yang <[email protected]> Jeffrey Yasskin <[email protected]> Joey Ye <[email protected]> Kwok Cheung Yeung <[email protected]> Greta Yorsh <[email protected]> David Yuste <[email protected]> Adhemerval Zanella <[email protected]> Dennis Zhang <[email protected]> Yufeng Zhang <[email protected]> Qing Zhao <[email protected]> Shujing Zhao <[email protected]> Jon Ziegler <[email protected]> Roman Zippel <[email protected]> Josef Zlomek <[email protected]> + Dominique d'Humieres <[email protected]> Bug database only accounts are fine! Contributing under the DCO are fine! contrib/ChangeLog: * check-MAINTAINERS.py: New file. --- contrib/check-MAINTAINERS.py | 100 +++++++++++++++++++++++++++++++++++ 1 file changed, 100 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..70aa375846b --- /dev/null +++ b/contrib/check-MAINTAINERS.py @@ -0,0 +1,100 @@ +#!/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): + parts = line.split('\t') + surname = parts[0].split()[-1] + 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
