mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 08:34:19 +01:00
Fix merge script to prompt if tests are still in progress
This commit is contained in:
@@ -97,12 +97,44 @@ def wrap_text(text, width=72):
|
||||
return "\n".join(wrapped_lines)
|
||||
|
||||
|
||||
def merge_remote(pr_number: int, commit_message: str, commit_title: str):
|
||||
output, error, returncode = run_command(f"gh pr checks {pr_number} --json state")
|
||||
if returncode == 0:
|
||||
def check_pr_status(pr_number):
|
||||
"""Check the status of all checks for a PR
|
||||
|
||||
Returns a tuple of (has_failing, has_pending) indicating if there are
|
||||
any failing or pending checks respectively.
|
||||
"""
|
||||
output, error, returncode = run_command(f"gh pr checks {pr_number} --json state,name,startedAt,completedAt")
|
||||
if returncode != 0:
|
||||
print(f"Warning: Unable to get PR check status: {error}")
|
||||
return False, False
|
||||
|
||||
checks_data = json.loads(output)
|
||||
if checks_data and any(check.get("state") == "FAILURE" for check in checks_data):
|
||||
print("Warning: Some checks are failing")
|
||||
if not checks_data:
|
||||
return False, False
|
||||
|
||||
has_failing = any(check.get("state") == "FAILURE" for check in checks_data)
|
||||
has_pending = any(
|
||||
check.get("startedAt") and not check.get("completedAt") or check.get("state") == "IN_PROGRESS"
|
||||
for check in checks_data
|
||||
)
|
||||
return has_failing, has_pending
|
||||
|
||||
|
||||
def merge_remote(pr_number: int, commit_message: str, commit_title: str):
|
||||
has_failing, has_pending = check_pr_status(pr_number)
|
||||
|
||||
prompt_needed = False
|
||||
warning_msg = ""
|
||||
|
||||
if has_failing:
|
||||
prompt_needed = True
|
||||
warning_msg = "Warning: Some checks are failing"
|
||||
elif has_pending:
|
||||
prompt_needed = True
|
||||
warning_msg = "Warning: Some checks are still running"
|
||||
|
||||
if prompt_needed:
|
||||
print(warning_msg)
|
||||
if input("Do you want to proceed with the merge? (y/N): ").strip().lower() != "y":
|
||||
exit(0)
|
||||
|
||||
@@ -131,6 +163,23 @@ def merge_remote(pr_number: int, commit_message: str, commit_title: str):
|
||||
|
||||
|
||||
def merge_local(pr_number: int, commit_message: str):
|
||||
has_failing, has_pending = check_pr_status(pr_number)
|
||||
|
||||
prompt_needed = False
|
||||
warning_msg = ""
|
||||
|
||||
if has_failing:
|
||||
prompt_needed = True
|
||||
warning_msg = "Warning: Some checks are failing"
|
||||
elif has_pending:
|
||||
prompt_needed = True
|
||||
warning_msg = "Warning: Some checks are still running"
|
||||
|
||||
if prompt_needed:
|
||||
print(warning_msg)
|
||||
if input("Do you want to proceed with the merge? (y/N): ").strip().lower() != "y":
|
||||
exit(0)
|
||||
|
||||
current_branch, _, _ = run_command("git branch --show-current")
|
||||
|
||||
print(f"Fetching PR #{pr_number}...")
|
||||
|
||||
Reference in New Issue
Block a user