Skip to content

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

Merged
EnricoMi merged 4 commits intoPyGithub:mainfrom
fetsko:fetsko/fix-PullRequest.delete_branch
Oct 27, 2024
Merged

PullRequest.delete_branch: fix the remaining pull requests check#3063
EnricoMi merged 4 commits intoPyGithub:mainfrom
fetsko:fetsko/fix-PullRequest.delete_branch

Conversation

@fetsko
Copy link
Copy Markdown
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}")

@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
Copy Markdown
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
@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.

2 participants