]>
Commit | Line | Data |
---|---|---|
c10aa1f0 | 1 | #!/usr/bin/env python3 |
81f86cb9 | 2 | |
83ffe9cd | 3 | # Copyright (C) 2020-2023 Free Software Foundation, Inc. |
c10aa1f0 ML |
4 | # |
5 | # This file is part of GCC. | |
6 | # | |
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 | |
10 | # version. | |
11 | # | |
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 | |
15 | # for more details. | |
16 | # | |
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/>. */ | |
20 | ||
21 | import argparse | |
22 | ||
23 | from git_repository import parse_git_revisions | |
24 | ||
25 | parser = argparse.ArgumentParser(description='Check git ChangeLog format ' | |
26 | 'of a commit') | |
e4f0e06b | 27 | parser.add_argument('revisions', default='HEAD', nargs='?', |
8300c346 TB |
28 | help='Git revisions (e.g. hash~5..hash or just hash) - ' |
29 | 'if not specified: HEAD') | |
c10aa1f0 ML |
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') | |
af1bfcc0 ML |
34 | parser.add_argument('-v', '--verbose', action='store_true', |
35 | help='Print verbose information') | |
c10aa1f0 ML |
36 | args = parser.parse_args() |
37 | ||
38 | retval = 0 | |
8f67bf25 | 39 | for git_commit in parse_git_revisions(args.git_path, args.revisions): |
e4f0e06b | 40 | res = 'OK' if git_commit.success else 'FAILED' |
b05c4c2c | 41 | print('Checking %s: %s' % (git_commit.original_info.hexsha, res)) |
c10aa1f0 | 42 | if git_commit.success: |
c10aa1f0 ML |
43 | if args.print_changelog: |
44 | git_commit.print_output() | |
2b2cec58 TB |
45 | if args.verbose and git_commit.warnings: |
46 | for warning in git_commit.warnings: | |
47 | print('WARN: %s' % warning) | |
c10aa1f0 | 48 | else: |
2b2cec58 TB |
49 | if args.verbose and git_commit.warnings: |
50 | for warning in git_commit.warnings: | |
51 | print('WARN: %s' % warning) | |
c10aa1f0 ML |
52 | for error in git_commit.errors: |
53 | print('ERR: %s' % error) | |
af1bfcc0 ML |
54 | if args.verbose and error.details: |
55 | print(error.details) | |
c10aa1f0 ML |
56 | retval = 1 |
57 | ||
58 | exit(retval) |