This is an automated email from the ASF dual-hosted git repository.

andor pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/branch-3.7 by this push:
     new f7a7d41bc Zookeeper 4756: [Addendum] Refactor commit message handling 
in merge_pr function (#2095)
f7a7d41bc is described below

commit f7a7d41bcecdeba516abdb44470bdbc5f17a5534
Author: szucsvillo <81696283+szucsvi...@users.noreply.github.com>
AuthorDate: Mon Dec 4 11:13:36 2023 +0100

    Zookeeper 4756: [Addendum] Refactor commit message handling in merge_pr 
function (#2095)
    
    Change-Id: I7c738b31b8f5991bc5f93118285c561c2a4719af
    
    Co-authored-by: Villő Szűcs <szucsvi...@cloudera.com>
    (cherry picked from commit 2445fe6fa87a2971cb05fe8da82926c17d82051f)
    Signed-off-by: Andor Molnar <an...@apache.org>
---
 zk-merge-pr.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/zk-merge-pr.py b/zk-merge-pr.py
index debc36e31..5358cbd97 100755
--- a/zk-merge-pr.py
+++ b/zk-merge-pr.py
@@ -126,13 +126,19 @@ def get_current_branch():
 # merge the requested PR and return the merge hash
 def merge_pr(pr_num, title, pr_repo_desc):
 
-    # Retrieve the commits separately.
-    json_commits = 
get_json(f"https://api.github.com/repos/{PUSH_REMOTE_NAME}/{PROJECT_NAME}/pulls/{pr_num}/commits";)
     merge_message = []
-    if json_commits and isinstance(json_commits, list):
-        for commit in json_commits:
-            commit_message = commit['commit']['message']
-            merge_message += [commit_message]
+    result = input("Would you like to squash the commit messages? (y/n): ")
+    if result.lower().strip() == "y":
+        # Retrieve the commits separately.
+        json_commits = 
get_json(f"https://api.github.com/repos/{PUSH_REMOTE_NAME}/{PROJECT_NAME}/pulls/{pr_num}/commits";)
+        if json_commits and isinstance(json_commits, list):
+            for commit in json_commits:
+                commit_message = commit['commit']['message']
+                # Remove empty lines and lines containing "Change-Id:"
+                filtered_lines = [line for line in commit_message.split('\n') 
if 'Change-Id:' not in line and line.strip()]
+                modified_commit_message = '\n'.join(filtered_lines)
+                if modified_commit_message.strip() != title.strip():
+                    merge_message += [modified_commit_message]
 
     # Check for disapproval reviews.
     json_reviewers = 
get_json(f"https://api.github.com/repos/{PUSH_REMOTE_NAME}/{PROJECT_NAME}/pulls/{pr_num}/reviews";)

Reply via email to