diff options
author | Ken Matsui <kmatsui@gcc.gnu.org> | 2024-02-28 13:00:23 -0800 |
---|---|---|
committer | Ken Matsui <kmatsui@gcc.gnu.org> | 2024-05-06 10:08:33 -0700 |
commit | 0e12aa6c26a9566f5b1a9b6d111a9e27507e213d (patch) | |
tree | b09b2e0b728117ee06428eb030e8f96df9078247 /contrib | |
parent | 80c03ac8041340b29325f86ed58ea8bd40a55b99 (diff) | |
download | gcc-0e12aa6c26a9566f5b1a9b6d111a9e27507e213d.zip gcc-0e12aa6c26a9566f5b1a9b6d111a9e27507e213d.tar.gz gcc-0e12aa6c26a9566f5b1a9b6d111a9e27507e213d.tar.bz2 |
contrib/gcc-changelog/git_check_commit.py: Implement --num-commits
This patch implements a --num-commits (-n) flag for shorthand for
the range of hash~N..hash commits.
contrib/ChangeLog:
* gcc-changelog/git_check_commit.py: Implement --num-commits.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/gcc-changelog/git_check_commit.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/contrib/gcc-changelog/git_check_commit.py b/contrib/gcc-changelog/git_check_commit.py index 8cca9f4..22e032e 100755 --- a/contrib/gcc-changelog/git_check_commit.py +++ b/contrib/gcc-changelog/git_check_commit.py @@ -22,6 +22,12 @@ import argparse from git_repository import parse_git_revisions +def nonzero_uint(value): + ivalue = int(value) + if ivalue <= 0: + raise argparse.ArgumentTypeError('%s is not a non-zero positive integer' % value) + return ivalue + parser = argparse.ArgumentParser(description='Check git ChangeLog format ' 'of a commit') parser.add_argument('revisions', default='HEAD', nargs='?', @@ -33,8 +39,17 @@ parser.add_argument('-p', '--print-changelog', action='store_true', help='Print final changelog entires') parser.add_argument('-v', '--verbose', action='store_true', help='Print verbose information') +parser.add_argument('-n', '--num-commits', type=nonzero_uint, default=1, + help='Number of commits to check (i.e. shorthand for ' + 'hash~N..hash)') args = parser.parse_args() +if args.num_commits > 1: + if '..' in args.revisions: + print('ERR: --num-commits and range of revisions are mutually exclusive') + exit(1) + args.revisions = '{0}~{1}..{0}'.format(args.revisions, args.num_commits) + retval = 0 for git_commit in parse_git_revisions(args.git_path, args.revisions): res = 'OK' if git_commit.success else 'FAILED' |