On 1/11/22 11:05, Martin Liška wrote:
On 1/11/22 10:38, Jakub Jelinek wrote:
On Tue, Jan 11, 2022 at 10:27:19AM +0100, Martin Liška wrote:
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:

I'm still surprised by what the sort is doing,
( echo Chene; echo Chêne; echo Chfne ) | LC_ALL=en_US.UTF-8 sort
Chene
Chêne
Chfne
That is on glibc 2.32.  On glibc 2.34.9000 I get a different order though,
Chêne last.
That partly ruins the idea of the checking script when the sorting isn't
the same for many people, either the script will be failing for many people
or various people will be changing the order there and back all the time.

    Jakub


Or we can utilize https://pypi.org/project/Unidecode python package that 
provides:

In [7]: unidecode.unidecode('Jääskeläinen')
Out[7]: 'Jaaskelainen'

and sort it by that.

Martin

I'm going to push the change and re-order 2 names and we should be done.

Martin
From 8ad2115c48a8f30c05000c8c3d908a264a4eb1be Mon Sep 17 00:00:00 2001
From: Martin Liska <mli...@suse.cz>
Date: Tue, 11 Jan 2022 14:10:14 +0100
Subject: [PATCH 2/2] Sort 2 names in ChangeLog.

ChangeLog:

	* MAINTAINERS: Sort 2 names.
---
 MAINTAINERS | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index c5aeb1af174..9b5945c048d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18,6 +18,9 @@ To report problems in GCC, please visit:
 Note: when adding someone to a more specific section please remove any
 corresponding entry from the Write After Approval list.
 
+Note: please verify that sorting is correct with:
+./contrib/check-MAINTAINERS.py MAINTAINERS
+
 Maintainers
 ===========
 
@@ -422,6 +425,7 @@ Haochen Gui					<guih...@gcc.gnu.org>
 Jiufu Guo					<guoji...@linux.ibm.com>
 Xuepeng Guo					<terry.xp...@gmail.com>
 Wei Guozhi					<car...@google.com>
+Naveen H.S					<nave...@marvell.com>
 Mostafa Hagog					<ha...@gcc.gnu.org>
 Andrew Haley					<a...@redhat.com>
 Frederik Harwath				<frede...@codesourcery.com>
@@ -447,7 +451,6 @@ Dominique d'Humieres				<domi...@lps.ens.fr>
 Andy Hutchinson					<hutchinsona...@aim.com>
 Joel Hutton					<joel.hut...@arm.com>
 Lewis Hyatt					<lhy...@gmail.com>
-Naveen H.S					<nave...@marvell.com>
 Roland Illig					<roland.il...@gmx.de>
 Meador Inge					<mead...@codesourcery.com>
 Bernardo Innocenti				<ber...@develer.com>
@@ -484,12 +487,12 @@ Louis Krupp					<louis.kr...@zoho.com>
 Prathamesh Kulkarni				<prathamesh.kulka...@linaro.org>
 Venkataramanan Kumar				<venkataramanan.ku...@amd.com>
 Doug Kwan					<dougk...@google.com>
+Aaron W. LaFramboise				<aaronava...@aaronwl.com>
 Scott Robert Ladd				<scott.l...@coyotegulch.com>
 Razya Ladelsky					<ra...@gcc.gnu.org>
 Thierry Lafage					<thierry.laf...@inria.fr>
 Rask Ingemann Lambertsen			<ccc94...@vip.cybercity.dk>
 Jerome Lambourg					<lambo...@adacore.com>
-Aaron W. LaFramboise				<aaronava...@aaronwl.com>
 Asher Langton					<langt...@llnl.gov>
 Chris Lattner					<sa...@nondot.org>
 Terry Laurenzo					<tlaure...@gmail.com>
-- 
2.34.1

From f770f4913a8247c284dbeb74ba493496b70fe720 Mon Sep 17 00:00:00 2001
From: Martin Liska <mli...@suse.cz>
Date: Mon, 10 Jan 2022 16:49:31 +0100
Subject: [PATCH 1/2] Check sorting of MAINTAINERS.

contrib/ChangeLog:

	* check-MAINTAINERS.py: New file.
---
 contrib/check-MAINTAINERS.py | 113 +++++++++++++++++++++++++++++++++++
 1 file changed, 113 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..ca7bb291282
--- /dev/null
+++ b/contrib/check-MAINTAINERS.py
@@ -0,0 +1,113 @@
+#!/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
+
+import unidecode
+
+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'
+
+    # Remove accents
+    return (unidecode.unidecode(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