Skip to content

Commit 6ace4df

Browse files
committed
[RR] Add Interactive settings
The new feature allows a user to run in interactive mode where the rolling release will "pause" while the engineer fixes the failed forward-port and commit. It will then attempt to continue.
1 parent 2e1c3ba commit 6ace4df

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

rolling-release-update.py

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
161161
"--demo", help="DEMO mode, will make a new set of branches with demo_ prepended", action="store_true"
162162
)
163163
parser.add_argument("--debug", help="Enable debug output", action="store_true")
164+
parser.add_argument(
165+
"--interactive", help="Interactive mode - pause on merge conflicts for user resolution", action="store_true"
166+
)
164167
args = parser.parse_args()
165168

166169
if args.demo:
@@ -366,6 +369,80 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
366369
if result.returncode != 0:
367370
print(f"[rolling release update] ERROR: Failed to cherry-pick commit {ciq_commit}")
368371
print(result.stderr.decode("utf-8"))
369-
exit(1)
372+
373+
if args.interactive:
374+
print("[rolling release update] ========================================")
375+
print("[rolling release update] INTERACTIVE MODE: Merge conflict detected")
376+
print("[rolling release update] ========================================")
377+
print("[rolling release update] Please resolve or skip the merge conflict manually.")
378+
print("[rolling release update] To resolve:")
379+
print("[rolling release update] 1. Fix merge conflicts in the working directory")
380+
print("[rolling release update] 2. Stage resolved files: git add <files>")
381+
print("[rolling release update] 3. Complete cherry-pick: git cherry-pick --continue")
382+
print("[rolling release update] (or commit manually if needed)")
383+
print("[rolling release update] To skip:")
384+
print("[rolling release update] 1. To skip this commit: git cherry-pick --skip")
385+
print("[rolling release update] When done:")
386+
print("[rolling release update] Return here and press Enter to continue")
387+
print("[rolling release update] ========================================")
388+
389+
# Loop until conflict is resolved or user aborts
390+
while True:
391+
user_input = input(
392+
'[rolling release update] Press Enter when resolved (or type "stop"/"abort" to exit): '
393+
).strip().lower()
394+
395+
if user_input in ["stop", "abort"]:
396+
print("[rolling release update] ========================================")
397+
print("[rolling release update] User aborted. Remaining commits to forward port:")
398+
print("[rolling release update] ========================================")
399+
400+
# Print remaining commits including the current failed one
401+
remaining_commits = list(reversed(rolling_commit_map.items()))
402+
start_idx = remaining_commits.index((ciq_commit, upstream_commit))
403+
404+
for remaining_commit, remaining_upstream in remaining_commits[start_idx:]:
405+
short_sha = repo.git.rev_parse("--short", remaining_commit)
406+
summary = repo.git.show("--pretty=%s", "-s", remaining_commit)
407+
print(f" {short_sha} {summary}")
408+
409+
print("[rolling release update] ========================================")
410+
print(f"[rolling release update] Total remaining: {len(remaining_commits) - start_idx} commits")
411+
exit(1)
412+
413+
# Verify the cherry-pick was completed successfully
414+
# Check if CHERRY_PICK_HEAD still exists (indicates incomplete cherry-pick)
415+
cherry_pick_head = os.path.join(args.repo, ".git", "CHERRY_PICK_HEAD")
416+
if os.path.exists(cherry_pick_head):
417+
print("[rolling release update] ERROR: Cherry-pick not completed (.git/CHERRY_PICK_HEAD still exists)")
418+
print("[rolling release update] Please complete the cherry-pick with:")
419+
print("[rolling release update] git cherry-pick --continue")
420+
print("[rolling release update] or abort with:")
421+
print("[rolling release update] git cherry-pick --abort")
422+
print('[rolling release update] Type "stop" or "abort" to exit, or press Enter to check again')
423+
continue
424+
425+
# Check for uncommitted changes
426+
status_result = subprocess.run(
427+
["git", "status", "--porcelain"], stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=args.repo
428+
)
429+
if status_result.returncode != 0:
430+
print("[rolling release update] ERROR: Could not check git status")
431+
print('[rolling release update] Type "stop" or "abort" to exit, or press Enter to check again')
432+
continue
433+
434+
if status_result.stdout.strip():
435+
print("[rolling release update] ERROR: There are still uncommitted changes")
436+
print("[rolling release update] Status:")
437+
print(status_result.stdout.decode("utf-8"))
438+
print("[rolling release update] Please commit or stash changes before continuing")
439+
print('[rolling release update] Type "stop" or "abort" to exit, or press Enter to check again')
440+
continue
441+
442+
# If we got here, everything is resolved
443+
print("[rolling release update] Cherry-pick resolved successfully, continuing...")
444+
break
445+
else:
446+
exit(1)
370447

371448
print(f"[rolling release update] Successfully applied all {commits_applied} commits")

0 commit comments

Comments
 (0)