3 # Copyright (C) 2020-2023 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 parser
= argparse
.ArgumentParser(description
='Check git ChangeLog format '
27 parser
.add_argument('revisions', default
='HEAD', nargs
='?',
28 help='Git revisions (e.g. hash~5..hash or just hash) - '
29 'if not specified: HEAD')
30 parser
.add_argument('-g', '--git-path', default
='.',
31 help='Path to git repository')
32 parser
.add_argument('-p', '--print-changelog', action
='store_true',
33 help='Print final changelog entires')
34 parser
.add_argument('-v', '--verbose', action
='store_true',
35 help='Print verbose information')
36 args
= parser
.parse_args()
39 for git_commit
in parse_git_revisions(args
.git_path
, args
.revisions
):
40 res
= 'OK' if git_commit
.success
else 'FAILED'
41 print('Checking %s: %s' % (git_commit
.original_info
.hexsha
, res
))
42 if git_commit
.success
:
43 if args
.print_changelog
:
44 git_commit
.print_output()
45 if args
.verbose
and git_commit
.warnings
:
46 for warning
in git_commit
.warnings
:
47 print('WARN: %s' % warning
)
49 if args
.verbose
and git_commit
.warnings
:
50 for warning
in git_commit
.warnings
:
51 print('WARN: %s' % warning
)
52 for error
in git_commit
.errors
:
53 print('ERR: %s' % error
)
54 if args
.verbose
and error
.details
: