From 60a8d9b2fdb7c204356dea2423e96d17e8634b60 Mon Sep 17 00:00:00 2001 From: Bruno Postle Date: Sun, 4 Jun 2023 22:47:10 +0100 Subject: [PATCH] Include commit summary of merged branches (#3096) Git merges usually transfer the commit history, but when we resolve a conflict with a 'mergetool' (ie. ifcmerge), this history is lost, everything is squashed into a single commit. Now a summary of the merged changes is appended to the merge message. --- src/blenderbim/blenderbim/tool/ifcgit.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/tool/ifcgit.py b/src/blenderbim/blenderbim/tool/ifcgit.py index 3507d8594a..f50f2e18ab 100644 --- a/src/blenderbim/blenderbim/tool/ifcgit.py +++ b/src/blenderbim/blenderbim/tool/ifcgit.py @@ -1,5 +1,6 @@ import os import re +import time # allows git import even if git executable isn't found os.environ["GIT_PYTHON_REFRESH"] = "quiet" @@ -421,7 +422,17 @@ class IfcGit: return False repo.index.add(path_ifc) - props.commit_message = "Merge branch '" + props.display_branch + "' into " + repo.active_branch.name + + message_summary = "" + branch_commits = repo.iter_commits(rev=repo.active_branch.name + ".." + props.display_branch) + for commit in branch_commits: + message_summary += "\n\n" + commit.author.name + " <" + commit.author.email + ">\n" + message_summary += time.strftime("%c", time.localtime(commit.committed_date)) + "\n" + message_summary += commit.message + + props.commit_message = ( + "Merge branch '" + props.display_branch + "' into " + repo.active_branch.name + message_summary + ) props.display_branch = repo.active_branch.name cls.load_project(path_ifc)