]>
git.ipfire.org Git - thirdparty/gcc.git/blob - contrib/gcc-changelog/git_check_commit.py
59405967e85b4fad270efb97c78b2e1952bc4550
3 # Copyright (C) 2020-2025 Free Software Foundation, Inc.
5 # This file is part of GCC.
7 # GCC is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3, or (at your option) any later
12 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 # You should have received a copy of the GNU General Public License
18 # along with GCC; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>.
23 from git_repository
import parse_git_revisions
25 def nonzero_uint(value
):
28 raise argparse
.ArgumentTypeError('%s is not a non-zero positive integer' % value
)
31 parser
= argparse
.ArgumentParser(description
='Check git ChangeLog format '
33 parser
.add_argument('revisions', default
='HEAD', nargs
='?',
34 help='Git revisions (e.g. hash~5..hash or just hash) - '
35 'if not specified: HEAD')
36 parser
.add_argument('-g', '--git-path', default
='.',
37 help='Path to git repository')
38 parser
.add_argument('-p', '--print-changelog', action
='store_true',
39 help='Print final changelog entires')
40 parser
.add_argument('-v', '--verbose', action
='store_true',
41 help='Print verbose information')
42 parser
.add_argument('-n', '--num-commits', type=nonzero_uint
, default
=1,
43 help='Number of commits to check (i.e. shorthand for '
45 args
= parser
.parse_args()
47 if args
.num_commits
> 1:
48 if '..' in args
.revisions
:
49 print('ERR: --num-commits and range of revisions are mutually exclusive')
51 args
.revisions
= '{0}~{1}..{0}'.format(args
.revisions
, args
.num_commits
)
54 for git_commit
in parse_git_revisions(args
.git_path
, args
.revisions
):
55 res
= 'OK' if git_commit
.success
else 'FAILED'
56 print('Checking %s: %s' % (git_commit
.original_info
.hexsha
, res
))
57 if git_commit
.success
:
58 if args
.print_changelog
:
59 git_commit
.print_output()
60 if args
.verbose
and git_commit
.warnings
:
61 for warning
in git_commit
.warnings
:
62 print('WARN: %s' % warning
)
64 if args
.verbose
and git_commit
.warnings
:
65 for warning
in git_commit
.warnings
:
66 print('WARN: %s' % warning
)
67 for error
in git_commit
.errors
:
68 print('ERR: %s' % error
)
69 if args
.verbose
and error
.details
: