Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify which files had merge conflicts while cherry-picking #1934

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actions/cherry_picker/cherrypick_with_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
failure_commits_str += "\n\nThe failed commits are NOT included in the PR. Please resolve manually.\ncc: @bazelbuild/triage"
issue_comment_body += failure_commits_str
elif len(failed_commits):
issue_comment_body = "Failed commmits (likely due to merge conflicts): "
issue_comment_body = "Failed commits (likely due to merge conflicts): "
for fail_commit in failed_commits:
issue_comment_body += f"https://github.com/{input_data['api_repo_name']}/commit/{fail_commit}, "
issue_comment_body = issue_comment_body[::-1].replace(" ,", ".", 1)[::-1] + "\nPlease resolve manually.\ncc: @bazelbuild/triage"
Expand Down
5 changes: 3 additions & 2 deletions actions/cherry_picker/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ def run_cherry_pick(is_prod, commit_id, target_branch_name):
cherrypick_status = subprocess.run(['git', 'cherry-pick', '-m', '1', commit_id])

lockfile_names = {"src/test/tools/bzlmod/MODULE.bazel.lock", "MODULE.bazel.lock"}
unmerged_all_files = str(subprocess.Popen(["git", "diff", "--name-only", "--diff-filter=U"], stdout=subprocess.PIPE).communicate()[0].decode()).split("\n")
unmerged_all_files = str(subprocess.Popen(["git", "diff", "--name-only", "--diff-filter=U"], stdout=subprocess.PIPE).communicate()[0].decode()).strip().split("\n")
unmerged_rest = [j for i,j in enumerate(unmerged_all_files) if j not in lockfile_names and j != ""]

if cherrypick_status.returncode != 0:
if len(unmerged_rest) == 0 and ("src/test/tools/bzlmod/MODULE.bazel.lock" in changed_files or "MODULE.bazel.lock" in changed_files):
update_lockfile(changed_files, True)
else:
subprocess.run(['git', 'cherry-pick', '--skip'])
raise Exception("Cherry-pick was attempted, but there may be merge conflict(s). Please resolve manually.\ncc: @bazelbuild/triage")
unmerged_files_names = "`" + "`\n`".join(unmerged_all_files) + "`"
raise Exception(f"Cherry-pick was attempted but there were merge conflicts in the following file(s). Please resolve manually.\n\n{unmerged_files_names}\n\ncc: @bazelbuild/triage")
elif cherrypick_status.returncode == 0 and ("src/test/tools/bzlmod/MODULE.bazel.lock" in changed_files or "MODULE.bazel.lock" in changed_files):
update_lockfile(changed_files, False)

Expand Down