mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
contrib/gcc-changelog/git_update_version.py: Improve diagnostic
contrib/ChangeLog: * gcc-changelog/git_update_version.py: Add '-i'/'--ignore' argument to add to-be-ignored commits via the command line. (ignored_commits): Rename from IGNORED_COMMITS and change type from tuple to set. (prepend_to_changelog_files): Show git hash if errors occurred. (update_current_branch): Mark argument as optional by defaulting to None.
This commit is contained in:
parent
ea793db568
commit
9596f6567c
@ -22,6 +22,7 @@ import argparse
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from git import Repo
|
||||
|
||||
@ -30,7 +31,7 @@ from git_repository import parse_git_revisions
|
||||
current_timestamp = datetime.datetime.now().strftime('%Y%m%d\n')
|
||||
|
||||
# Skip the following commits, they cannot be correctly processed
|
||||
IGNORED_COMMITS = (
|
||||
ignored_commits = {
|
||||
'c2be82058fb40f3ae891c68d185ff53e07f14f45',
|
||||
'04a040d907a83af54e0a98bdba5bfabc0ef4f700',
|
||||
'2e96b5f14e4025691b57d2301d71aa6092ed44bc',
|
||||
@ -41,7 +42,7 @@ IGNORED_COMMITS = (
|
||||
'040e5b0edbca861196d9e2ea2af5e805769c8d5d',
|
||||
'8057f9aa1f7e70490064de796d7a8d42d446caf8',
|
||||
'109f1b28fc94c93096506e3df0c25e331cef19d0',
|
||||
'39f81924d88e3cc197fc3df74204c9b5e01e12f7')
|
||||
'39f81924d88e3cc197fc3df74204c9b5e01e12f7'}
|
||||
|
||||
FORMAT = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
|
||||
logging.basicConfig(level=logging.INFO, format=FORMAT,
|
||||
@ -58,6 +59,7 @@ def read_timestamp(path):
|
||||
|
||||
def prepend_to_changelog_files(repo, folder, git_commit, add_to_git):
|
||||
if not git_commit.success:
|
||||
logging.info(f"While processing {git_commit.info.hexsha}:")
|
||||
for error in git_commit.errors:
|
||||
logging.info(error)
|
||||
raise AssertionError()
|
||||
@ -93,13 +95,15 @@ parser.add_argument('-d', '--dry-mode',
|
||||
' is expected')
|
||||
parser.add_argument('-c', '--current', action='store_true',
|
||||
help='Modify current branch (--push argument is ignored)')
|
||||
parser.add_argument('-i', '--ignore', action='append',
|
||||
help='list of commits to ignore')
|
||||
args = parser.parse_args()
|
||||
|
||||
repo = Repo(args.git_path)
|
||||
origin = repo.remotes['origin']
|
||||
|
||||
|
||||
def update_current_branch(ref_name):
|
||||
def update_current_branch(ref_name=None):
|
||||
commit = repo.head.commit
|
||||
commit_count = 1
|
||||
while commit:
|
||||
@ -123,7 +127,7 @@ def update_current_branch(ref_name):
|
||||
head = head.parents[1]
|
||||
commits = parse_git_revisions(args.git_path, '%s..%s'
|
||||
% (commit.hexsha, head.hexsha), ref_name)
|
||||
commits = [c for c in commits if c.info.hexsha not in IGNORED_COMMITS]
|
||||
commits = [c for c in commits if c.info.hexsha not in ignored_commits]
|
||||
for git_commit in reversed(commits):
|
||||
prepend_to_changelog_files(repo, args.git_path, git_commit,
|
||||
not args.dry_mode)
|
||||
@ -153,6 +157,9 @@ def update_current_branch(ref_name):
|
||||
else:
|
||||
logging.info('DATESTAMP unchanged')
|
||||
|
||||
if args.ignore is not None:
|
||||
for item in args.ignore:
|
||||
ignored_commits.update(set(i for i in re.split(r'\s*,\s*|\s+', item)))
|
||||
|
||||
if args.current:
|
||||
logging.info('=== Working on the current branch ===')
|
||||
|
Loading…
Reference in New Issue
Block a user