Hi Jakub,
Jakub Jelinek wrote:
On Mon, May 20, 2024 at 08:31:02AM +0200, Tobias Burnus wrote:
Hmm, there were now two daily bumps: [...] I really wonder why.
Because I've done it by hand.
Okay, that explains it.
I still do not understand why it slipped through at the first place; I
tried old versions down to r12-709-g772e5e82e3114f and it still FAIL for
the invalid commit ("ERR: cannot find a ChangeLog location in message").
Thus, I wonder whether the commit hook is active at all?!?
I have in ~gccadmin a gcc-changelog copy and adjusted update_version_git
script which doesn't use contrib/gcc-changelog subdirectory from the
checkout it makes but from the ~gccadmin directory,
[...]
I'm already using something similar in
my hack (just was doing it for even successful commits, but I think your
patch is better).
And, I think best would be if update_version_git script simply
accepted a list of ignored commits from the command line too,
passed it to the git_update_version.py script and that one
added those to IGNORED_COMMITS.
Updated version:
* Uses my diagnostic
* Adds an -i/--ignore argument for commits. Permits to use '-i hash1 -i
hash2' but also '-i hash1,hash2' or '-i "hash1 hash2'
* I changed the global variable to lower case as Python's style guide
states that all uppercase variables is for constants.
* The '=None' matches one of the current usages (no argument passed);
hence, it is now explicit and 'pylint' is happy.
OK for mainline?
Tobias
PS: I have not updated the hashes. If needed/wanted, I leave that to
you, Jakub.
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.
contrib/gcc-changelog/git_update_version.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/contrib/gcc-changelog/git_update_version.py b/contrib/gcc-changelog/git_update_version.py
index 24f6c43d0b2..c69a3a6897a 100755
--- a/contrib/gcc-changelog/git_update_version.py
+++ b/contrib/gcc-changelog/git_update_version.py
@@ -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 ===')