1#!/usr/bin/env python3 2# 3# This file is part of GCC. 4# 5# GCC is free software; you can redistribute it and/or modify it under 6# the terms of the GNU General Public License as published by the Free 7# Software Foundation; either version 3, or (at your option) any later 8# version. 9# 10# GCC is distributed in the hope that it will be useful, but WITHOUT ANY 11# WARRANTY; without even the implied warranty of MERCHANTABILITY or 12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13# for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with GCC; see the file COPYING3. If not see 17# <http://www.gnu.org/licenses/>. */ 18 19import argparse 20 21from git_repository import parse_git_revisions 22 23parser = argparse.ArgumentParser(description='Check git ChangeLog format ' 24 'of a commit') 25parser.add_argument('revisions', default='HEAD', nargs='?', 26 help='Git revisions (e.g. hash~5..hash or just hash)') 27parser.add_argument('-g', '--git-path', default='.', 28 help='Path to git repository') 29parser.add_argument('-p', '--print-changelog', action='store_true', 30 help='Print final changelog entires') 31parser.add_argument('-n', '--non-strict-mode', action='store_true', 32 help='Use non-strict mode (allow changes in ChangeLog and ' 33 'other automatically updated files).') 34args = parser.parse_args() 35 36retval = 0 37for git_commit in parse_git_revisions(args.git_path, args.revisions, 38 not args.non_strict_mode): 39 res = 'OK' if git_commit.success else 'FAILED' 40 print('Checking %s: %s' % (git_commit.original_info.hexsha, res)) 41 if git_commit.success: 42 if args.print_changelog: 43 git_commit.print_output() 44 else: 45 for error in git_commit.errors: 46 print('ERR: %s' % error) 47 retval = 1 48 49exit(retval) 50