gcc-changelog: support merge commits in git_update_version

Message ID 6ed37e2d-b899-cf64-2652-635acd16113b@suse.cz
State New
Headers show
Series
  • gcc-changelog: support merge commits in git_update_version
Related show

Commit Message

Martin Liška June 18, 2020, 12:16 p.m.
The patch addresses need to generate ChangeLog for a vendor branch
(redhat/gcc-10-branch) that can contain merge commits.

Tested on c518050989be3a224a04a8b33d73f37a16c30fbb and current active branches.
Jakub: Can you please test it?

Martin

contrib/ChangeLog:

	* gcc-changelog/git_update_version.py: Support merge commits
	and walk only on the branch that is being merged and generate
	missing ChangeLog entries.
---
  contrib/gcc-changelog/git_update_version.py | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)

-- 
2.27.0

Comments

Martin Sebor via Gcc-patches June 18, 2020, 12:28 p.m. | #1
On Thu, Jun 18, 2020 at 02:16:32PM +0200, Martin Liška wrote:
> The patch addresses need to generate ChangeLog for a vendor branch

> (redhat/gcc-10-branch) that can contain merge commits.

> 

> Tested on c518050989be3a224a04a8b33d73f37a16c30fbb and current active branches.

> Jakub: Can you please test it?


Works for me, LGTM, thanks.

> contrib/ChangeLog:

> 

> 	* gcc-changelog/git_update_version.py: Support merge commits

> 	and walk only on the branch that is being merged and generate

> 	missing ChangeLog entries.


	Jakub
Martin Liška June 18, 2020, 12:31 p.m. | #2
On 6/18/20 2:28 PM, Jakub Jelinek wrote:
> On Thu, Jun 18, 2020 at 02:16:32PM +0200, Martin Liška wrote:

>> The patch addresses need to generate ChangeLog for a vendor branch

>> (redhat/gcc-10-branch) that can contain merge commits.

>>

>> Tested on c518050989be3a224a04a8b33d73f37a16c30fbb and current active branches.

>> Jakub: Can you please test it?

> 

> Works for me, LGTM, thanks.


Good, I've just pushed the script.

Martin

> 

>> contrib/ChangeLog:

>>

>> 	* gcc-changelog/git_update_version.py: Support merge commits

>> 	and walk only on the branch that is being merged and generate

>> 	missing ChangeLog entries.

> 

> 	Jakub

>

Patch

diff --git a/contrib/gcc-changelog/git_update_version.py b/contrib/gcc-changelog/git_update_version.py
index 733a1a0f14a..7077880cf80 100755
--- a/contrib/gcc-changelog/git_update_version.py
+++ b/contrib/gcc-changelog/git_update_version.py
@@ -81,15 +81,23 @@  def update_current_branch():
          if (commit.author.email == 'gccadmin@gcc.gnu.org'
                  and commit.message.strip() == 'Daily bump.'):
              break
-        commit = commit.parents[0]
+        # We support merge commits but only with 2 parensts
+        assert len(commit.parents) <= 2
+        commit = commit.parents[-1]
          commit_count += 1
  
      print('%d revisions since last Daily bump' % commit_count)
      datestamp_path = os.path.join(args.git_path, 'gcc/DATESTAMP')
      if (read_timestamp(datestamp_path) != current_timestamp
              or args.dry_mode or args.current):
-        commits = parse_git_revisions(args.git_path, '%s..HEAD'
-                                      % commit.hexsha)
+        head = repo.head.commit
+        # if HEAD is a merge commit, start with second parent
+        # (branched that is being merged into the current one)
+        assert len(head.parents) <= 2
+        if len(head.parents) == 2:
+            head = head.parents[1]
+        commits = parse_git_revisions(args.git_path, '%s..%s'
+                                      % (commit.hexsha, head.hexsha))
          for git_commit in reversed(commits):
              prepend_to_changelog_files(repo, args.git_path, git_commit,
                                         not args.dry_mode)