aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <tburnus@baylibre.com>2025-05-22 17:06:38 +0200
committerTobias Burnus <tburnus@baylibre.com>2025-05-22 17:06:38 +0200
commitcc7f48e65b9aadb885461dea201d6028cc008ea1 (patch)
tree8a5fb3bc732567eb07fbb8804453a1627b08ed2a
parentbc76738d12f06a5efc2b998c2d6fcc093288771f (diff)
downloadgcc-cc7f48e65b9aadb885461dea201d6028cc008ea1.zip
gcc-cc7f48e65b9aadb885461dea201d6028cc008ea1.tar.gz
gcc-cc7f48e65b9aadb885461dea201d6028cc008ea1.tar.bz2
git_repository.py: Fix handling of --last-commit with merges
contrib/ChangeLog: * gcc-changelog/git_update_version.py (update_current_branch): Fix handling of merges. * gcc-changelog/git_repository.py (parse_git_revisions): Skip over merge commits for merges from exclude branch.
-rwxr-xr-xcontrib/gcc-changelog/git_repository.py9
-rwxr-xr-xcontrib/gcc-changelog/git_update_version.py28
2 files changed, 21 insertions, 16 deletions
diff --git a/contrib/gcc-changelog/git_repository.py b/contrib/gcc-changelog/git_repository.py
index dc658af..c70307d 100755
--- a/contrib/gcc-changelog/git_repository.py
+++ b/contrib/gcc-changelog/git_repository.py
@@ -77,8 +77,13 @@ def parse_git_revisions(repo_path, revisions, ref_name=None,
commits = [repo.commit(revisions)]
for commit in commits:
- if exclude_branch is not None and repo.is_ancestor(commit, exclude_branch):
- continue
+ if exclude_branch is not None:
+ if repo.is_ancestor(commit, exclude_branch):
+ continue
+ # Exlude merge commit
+ if (len(commit.parents) == 2
+ and repo.is_ancestor(commit.parents[1], exclude_branch)):
+ continue
git_commit = GitCommit(commit_to_info(commit.hexsha),
commit_to_info_hook=commit_to_info,
ref_name=ref_name)
diff --git a/contrib/gcc-changelog/git_update_version.py b/contrib/gcc-changelog/git_update_version.py
index ec5951c..ae2630e 100755
--- a/contrib/gcc-changelog/git_update_version.py
+++ b/contrib/gcc-changelog/git_update_version.py
@@ -124,21 +124,19 @@ def update_current_branch(ref_name=None, suffix="", last_commit_ref=None,
exclude_branch=None):
commit = repo.head.commit
commit_count = 1
- last_commit = (repo.commit(last_commit_ref)
- if last_commit_ref is not None else None)
- while commit:
- if last_commit is not None:
- if last_commit == commit:
+ if last_commit_ref is not None:
+ commit = repo.commit(last_commit_ref)
+ else:
+ while commit:
+ if (commit.author.email == 'gccadmin@gcc.gnu.org'
+ and commit.message.strip() == 'Daily bump.'):
break
- elif (commit.author.email == 'gccadmin@gcc.gnu.org'
- and commit.message.strip() == 'Daily bump.'):
- break
- # We support merge commits but only with 2 parensts
- assert len(commit.parents) <= 2
- commit = commit.parents[-1]
- commit_count += 1
-
- logging.info('%d revisions since last Daily bump' % commit_count)
+ # We support merge commits but only with 2 parensts
+ assert len(commit.parents) <= 2
+ commit = commit.parents[-1]
+ commit_count += 1
+ logging.info('%d revisions since last Daily bump' % commit_count)
+
datestamp_path = os.path.join(args.git_path, 'gcc/DATESTAMP')
if suffix != "":
if not os.path.exists(datestamp_path + suffix):
@@ -158,6 +156,8 @@ def update_current_branch(ref_name=None, suffix="", last_commit_ref=None,
% (commit.hexsha, head.hexsha), ref_name,
exclude_branch)
commits = [c for c in commits if c.info.hexsha not in ignored_commits]
+ if last_commit_ref is not None:
+ logging.info('%d revisions since last Daily bump' % len(commits))
for git_commit in reversed(commits):
prepend_to_changelog_files(repo, args.git_path, git_commit,
not args.dry_mode, args.suffix)