Skip to content

Commit

Permalink
When sync-typeshed fails to apply CP allow manual user merges (#15591)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
3 people authored Jul 4, 2023
1 parent 85ba574 commit 59ba429
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion misc/sync-typeshed.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,21 @@ def main() -> None:
"9f3bbbeb1", # ParamSpec for functools.wraps
]
for commit in commits_to_cherry_pick:
subprocess.run(["git", "cherry-pick", commit], check=True)
try:
subprocess.run(["git", "cherry-pick", commit], check=True)
except subprocess.CalledProcessError:
if not sys.__stdin__.isatty():
# We're in an automated context
raise

# Allow the option to merge manually
print(
f"Commit {commit} failed to cherry pick."
" In a separate shell, please manually merge and continue cherry pick."
)
rsp = input("Did you finish the cherry pick? [y/N]: ")
if rsp.lower() not in {"y", "yes"}:
raise
print(f"Cherry-picked {commit}.")

if args.make_pr:
Expand Down

0 comments on commit 59ba429

Please sign in to comment.