Skip to content

Commit 561c106

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 bcb91b2 commit 561c106

1 file changed

Lines changed: 69 additions & 1 deletion

File tree

rolling-release-update.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
124124
parser.add_argument('--demo', help='DEMO mode, will make a new set of branches with demo_ prepended',
125125
action='store_true')
126126
parser.add_argument('--debug', help='Enable debug output', action='store_true')
127+
parser.add_argument('--interactive', help='Interactive mode - pause on merge conflicts for user resolution',
128+
action='store_true')
127129
args = parser.parse_args()
128130

129131
if args.demo:
@@ -301,7 +303,73 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
301303
if result.returncode != 0:
302304
print(f'[rolling release update] ERROR: Failed to cherry-pick commit {ciq_commit}')
303305
print(result.stderr.decode('utf-8'))
304-
exit(1)
306+
307+
if args.interactive:
308+
print('[rolling release update] ========================================')
309+
print('[rolling release update] INTERACTIVE MODE: Merge conflict detected')
310+
print('[rolling release update] ========================================')
311+
print('[rolling release update] To resolve:')
312+
print('[rolling release update] 1. Fix merge conflicts in the working directory')
313+
print('[rolling release update] 2. Stage resolved files: git add <files>')
314+
print('[rolling release update] 3. Complete cherry-pick: git cherry-pick --continue')
315+
print('[rolling release update] (or commit manually if needed)')
316+
print('[rolling release update] ========================================')
317+
318+
# Loop until conflict is resolved or user aborts
319+
while True:
320+
user_input = input('[rolling release update] Press Enter when resolved (or type "stop"/"abort" to exit): ').strip().lower()
321+
322+
if user_input in ['stop', 'abort']:
323+
print('[rolling release update] ========================================')
324+
print('[rolling release update] User aborted. Remaining commits to forward port:')
325+
print('[rolling release update] ========================================')
326+
327+
# Print remaining commits including the current failed one
328+
remaining_commits = list(reversed(rolling_commit_map.items()))
329+
start_idx = remaining_commits.index((ciq_commit, upstream_commit))
330+
331+
for remaining_commit, remaining_upstream in remaining_commits[start_idx:]:
332+
short_sha = repo.git.rev_parse('--short', remaining_commit)
333+
summary = repo.git.show('--pretty=%s', '-s', remaining_commit)
334+
print(f' {short_sha} {summary}')
335+
336+
print('[rolling release update] ========================================')
337+
print(f'[rolling release update] Total remaining: {len(remaining_commits) - start_idx} commits')
338+
exit(1)
339+
340+
# Verify the cherry-pick was completed successfully
341+
# Check if CHERRY_PICK_HEAD still exists (indicates incomplete cherry-pick)
342+
cherry_pick_head = os.path.join(args.repo, '.git', 'CHERRY_PICK_HEAD')
343+
if os.path.exists(cherry_pick_head):
344+
print('[rolling release update] ERROR: Cherry-pick not completed (.git/CHERRY_PICK_HEAD still exists)')
345+
print('[rolling release update] Please complete the cherry-pick with:')
346+
print('[rolling release update] git cherry-pick --continue')
347+
print('[rolling release update] or abort with:')
348+
print('[rolling release update] git cherry-pick --abort')
349+
print('[rolling release update] Type "stop" or "abort" to exit, or press Enter to check again')
350+
continue
351+
352+
# Check for uncommitted changes
353+
status_result = subprocess.run(['git', 'status', '--porcelain'],
354+
stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=args.repo)
355+
if status_result.returncode != 0:
356+
print('[rolling release update] ERROR: Could not check git status')
357+
print('[rolling release update] Type "stop" or "abort" to exit, or press Enter to check again')
358+
continue
359+
360+
if status_result.stdout.strip():
361+
print('[rolling release update] ERROR: There are still uncommitted changes')
362+
print('[rolling release update] Status:')
363+
print(status_result.stdout.decode('utf-8'))
364+
print('[rolling release update] Please commit or stash changes before continuing')
365+
print('[rolling release update] Type "stop" or "abort" to exit, or press Enter to check again')
366+
continue
367+
368+
# If we got here, everything is resolved
369+
print('[rolling release update] Cherry-pick resolved successfully, continuing...')
370+
break
371+
else:
372+
exit(1)
305373

306374
print(f'[rolling release update] Successfully applied all {commits_applied} commits')
307375

0 commit comments

Comments
 (0)