Skip to content

Commit 59ba429

Browse files
svalentinpre-commit-ci[bot]AlexWaygood
authored
When sync-typeshed fails to apply CP allow manual user merges (#15591)
If misc/sync-typeshed.py fails to apply a cherry pick, it just fails. Let's try to give the user a chance to manually merge the CP and continue with the script. This should block for user input only in cases where stdin is a tty. So automation should continue failing. (but the only way to test is by running it) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alex Waygood <[email protected]>
1 parent 85ba574 commit 59ba429

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

misc/sync-typeshed.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,21 @@ def main() -> None:
185185
"9f3bbbeb1", # ParamSpec for functools.wraps
186186
]
187187
for commit in commits_to_cherry_pick:
188-
subprocess.run(["git", "cherry-pick", commit], check=True)
188+
try:
189+
subprocess.run(["git", "cherry-pick", commit], check=True)
190+
except subprocess.CalledProcessError:
191+
if not sys.__stdin__.isatty():
192+
# We're in an automated context
193+
raise
194+
195+
# Allow the option to merge manually
196+
print(
197+
f"Commit {commit} failed to cherry pick."
198+
" In a separate shell, please manually merge and continue cherry pick."
199+
)
200+
rsp = input("Did you finish the cherry pick? [y/N]: ")
201+
if rsp.lower() not in {"y", "yes"}:
202+
raise
189203
print(f"Cherry-picked {commit}.")
190204

191205
if args.make_pr:

0 commit comments

Comments
 (0)