Skip to content

Commit ede745f

Browse files
committed
ciq-cherry-pick.py: Add upstream-diff in the commit message in case of conflict
If the conflict is solved manually, then developer use ``` git commit ``` which will use the MERGE_MSG file for the commit message by default. Equivalent of ``` git commit -F MERGE_MSG ``` Therefore it makes sense to include "upstream-diff |" in the MERGE_MSG. In case the conflict is solved by cherry picking other commits, ciq-cherry-pick.py will be called again and MERGE_MSG will be rewritten, including the "upstream-diff" part. Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent 90eba28 commit ede745f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ciq-cherry-pick.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def check_fixes(sha):
3636
raise RuntimeError(f"The commit you want to cherry pick references a Fixes: {fix} but this is not here")
3737

3838

39-
def manage_commit_message(full_sha, ciq_tags, jira_ticket):
39+
def manage_commit_message(full_sha, ciq_tags, jira_ticket, commit_successful):
4040
"""
4141
It standardize the commit message by including the ciq_tags, original
4242
author and the original commit full sha.
@@ -60,7 +60,10 @@ def manage_commit_message(full_sha, ciq_tags, jira_ticket):
6060
with open(MERGE_MSG, "r") as file:
6161
original_msg = file.readlines()
6262

63-
new_msg = CIQ_cherry_pick_commit_standardization(original_msg, full_sha, jira=jira_ticket, tags=ciq_tags)
63+
optional_msg = "" if commit_successful else "upstream-diff |"
64+
new_msg = CIQ_cherry_pick_commit_standardization(
65+
original_msg, full_sha, jira=jira_ticket, tags=new_tags, optional_msg=optional_msg
66+
)
6467

6568
print(f"Cherry Pick New Message for {full_sha}")
6669
print(f"\n Original Message located here: {MERGE_MSG_BAK}")
@@ -90,12 +93,15 @@ def cherry_pick(sha, ciq_tags, jira_ticket):
9093

9194
# Commit message is in MERGE_MSG
9295
git_res = subprocess.run(["git", "cherry-pick", "-nsx", full_sha])
93-
manage_commit_message(full_sha=full_sha, ciq_tags=ciq_tags, jira_ticket=jira_ticket)
96+
commit_successful = True if git_res.returncode == 0 else False
97+
manage_commit_message(
98+
full_sha=full_sha, ciq_tags=ciq_tags, jira_ticket=jira_ticket, commit_successful=commit_successful
99+
)
94100

95-
if git_res.returncode != 0:
101+
if not commit_successful:
96102
error_str = (
97103
f"[FAILED] git cherry-pick -nsx {full_sha}\n"
98-
"Manually resolve conflict and include `upstream-diff` tag in commit message\n"
104+
"Manually resolve conflict and add explanation under `upstream-diff` tag in commit message\n"
99105
f"Subprocess Call: {git_res}"
100106
)
101107
raise RuntimeError(error_str)

0 commit comments

Comments
 (0)