Skip to content

PullRequest.delete_branch: fix the remaining pull requests check #3063

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 4 commits into from
Oct 27, 2024

Conversation

fetsko
Copy link
Contributor

@fetsko fetsko commented Oct 17, 2024

Problem

delete_branch(force=False) raises a RuntimeError if the repository has any open pull requests because the current check used for remaining open pull requests returns all open pull requests for the repository instead of only the open pull requests associated with the pull request's branch.

Fix

Updating this to use the format of user:ref-name or organization:ref-name appropriately gets open pull requests for the pull request's branch.

remaining_pulls = self.head.repo.get_pulls(head=f"{self.head.repo.owner.login}:{self.head.ref}")

Verified

This commit was signed with the committer’s verified signature.
Josh-Cena Joshua Chen

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@fetsko fetsko changed the title PullRequest.delete_branch: fix the remaining pull requests check in PullRequest.delete_branch PullRequest.delete_branch: fix the remaining pull requests check Oct 17, 2024
Copy link
Collaborator

@EnricoMi EnricoMi left a comment

Choose a reason for hiding this comment

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

LGTM!

@EnricoMi EnricoMi added this pull request to the merge queue Oct 27, 2024
Merged via the queue into PyGithub:main with commit 72fa627 Oct 27, 2024
14 checks passed
@fetsko fetsko deleted the fetsko/fix-PullRequest.delete_branch branch October 28, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants