(root)/
gcc-13.2.0/
contrib/
gcc-changelog/
git_check_commit.py
       1  #!/usr/bin/env python3
       2  
       3  # Copyright (C) 2020-2023 Free Software Foundation, Inc.
       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')
      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()
      37  
      38  retval = 0
      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)
      48      else:
      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:
      55                  print(error.details)
      56          retval = 1
      57  
      58  exit(retval)