Skip to content

Check that the bottom PR is mergeable #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/stack_pr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@

If you are trying land the stack, please update it first by calling 'submit'.

PR info from github: {d}
"""
ERROR_STACKINFO_PR_NOT_MERGEABLE = """Associated PR is not mergeable on GitHub!
{e}

Please fix the issues on GitHub.

PR info from github: {d}
"""
ERROR_REPO_DIRTY = """There are uncommitted changes.
Expand Down Expand Up @@ -424,7 +431,7 @@ def set_base_branches(st: List[StackEntry], target: str):

def verify(st: List[StackEntry], check_base: bool = False):
log(h("Verifying stack info"), level=1)
for e in st:
for index, e in enumerate(st):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index doesn't seem to be used here, do we need this particular change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used to test mergeability against only the bottom-most PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, my bad, I didn't realize the change below is in the same loop :)

if e.has_missing_info():
error(ERROR_STACKINFO_MISSING.format(**locals()))
raise RuntimeError
Expand All @@ -440,7 +447,7 @@ def verify(st: List[StackEntry], check_base: bool = False):
"view",
e.pr,
"--json",
"baseRefName,headRefName,number,state,body,title,url",
"baseRefName,headRefName,number,state,body,title,url,mergeStateStatus",
]
)
d = json.loads(ghinfo)
Expand Down Expand Up @@ -469,6 +476,11 @@ def verify(st: List[StackEntry], check_base: bool = False):
error(ERROR_STACKINFO_PR_BASE_MISMATCH.format(**locals()))
raise RuntimeError

# The first entry on the stack needs to be actually mergeable on GitHub.
if check_base and index == 0 and d["mergeStateStatus"] != "CLEAN":
error(ERROR_STACKINFO_PR_NOT_MERGEABLE.format(**locals()))
raise RuntimeError


def print_stack(st: List[StackEntry], level=1):
log(b("Stack:"), level=level)
Expand Down