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