]> gcc.gnu.org Git - gcc.git/blame - contrib/check-MAINTAINERS.py
tree-optimization/13962 - handle ptr-ptr compares in ptrs_compare_unequal
[gcc.git] / contrib / check-MAINTAINERS.py
CommitLineData
11b26b8d
ML
1#!/usr/bin/env python3
2
a945c346 3# Copyright (C) 2022-2024 Free Software Foundation, Inc.
11b26b8d
ML
4#
5# This file is part of GCC.
6#
7# GCC is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3, or (at your option)
10# any later version.
11#
12# GCC is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with GCC; see the file COPYING. If not, write to
19# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20# Boston, MA 02110-1301, USA.
21
22# Check that names in the file are sorted
23# alphabetically by surname.
24
25import locale
26import sys
27from difflib import ndiff
28from itertools import dropwhile, takewhile
29
30import unidecode
31
32locale.setlocale(locale.LC_ALL, 'en_US.utf8')
33
34exit_code = 0
35
36if len(sys.argv) != 2:
37 print('Usage: ./check-MAINTAINERS.py path-to/MAINTAINERS')
38 sys.exit(1)
39
40
41def sort_by_surname(line):
42 name = line.split('\t')[0]
43 parts = name.split()
44 surname = parts[-1]
45
46 # Special-case some names
47 if name == 'Stefan Schulze Frielinghaus':
48 surname = parts[1]
49 elif name == 'Kris Van Hees':
50 surname = parts[1]
51 elif surname == "d'Humieres":
52 surname = 'Humieres'
53
54 # Remove accents
55 return (unidecode.unidecode(surname), line)
56
57
58def has_tab(line):
59 return '\t' in line
60
61
62def is_empty(line):
63 return line
64
65
66def check_group(name, lines):
67 global exit_code
68
69 for line in lines:
70 if line.startswith(' '):
71 print(f'Line should not start with space: "{line}"')
72 exit_code = 2
73
1a809280
FK
74 # Special-case some names
75 if line == 'James Norris':
76 continue
77
78 if '\t' not in line:
79 print(f'Name and email should be separated by tabs: "{line}"')
80 exit_code = 2
81
11b26b8d
ML
82 lines = [line + '\n' for line in lines]
83 sorted_lines = sorted(lines, key=sort_by_surname)
84 if lines != sorted_lines:
85 exit_code = 1
86 diff = ndiff(lines, sorted_lines)
87 print(f'Wrong order for {name}:\n')
88 print(''.join(diff))
89 else:
90 print(f'{name} are fine!')
91
92
438f2a24 93lines = open(sys.argv[1]).read().splitlines()
11b26b8d
ML
94
95needle = 'Global Reviewers'
96lines = list(dropwhile(lambda x: x.strip() != needle, lines))
97lines = lines[2:]
98
99chunk = list(takewhile(is_empty, lines))
100check_group(needle, chunk)
101
102needle = 'Write After Approval'
103lines = list(dropwhile(lambda x: needle not in x, lines))
104lines = lines[2:]
105
106chunk = list(takewhile(is_empty, lines))
107check_group(needle, chunk)
108
109needle = 'Bug database only accounts'
110lines = list(dropwhile(lambda x: needle not in x, lines))
111lines = lines[2:]
112
113chunk = list(takewhile(is_empty, lines))
114check_group(needle, chunk)
115
116needle = 'Contributing under the DCO'
117lines = list(dropwhile(lambda x: needle not in x, lines))[1:]
118lines = list(dropwhile(lambda x: not has_tab(x), lines))
119check_group(needle, lines)
120
121sys.exit(exit_code)
This page took 0.230958 seconds and 5 git commands to generate.