-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Incorrect Pull Requests filtering in new delete_branch method #3031
Copy link
Copy link
Closed
Description
According to the GitHub API documentation, the head parameter should be in the format of user:ref-name or organization:ref-name. However, the current implementation in delete_branch method (introduced in v2.4.0) only uses ref-name, which leads to false-positive remaining_pulls (if repo contains any open PRs) with raising RuntimeErrors.
To reproduce (GITHUB_TOKEN omitted):
from github import Github
gh_client = Github(GITHUB_TOKEN)
org = 'PyGithub'
repository = gh_client.get_repo(f'{org}/PyGithub')
pr = repository.get_pull(2929)
pr_head_ref = pr.head.ref
# wrong head param usage - current implementation
# will return all open PRs in repository
prs = repository.get_pulls(head=f"{pr_head_ref}")
print(f"prs count: {prs.totalCount}")
for pr in prs:
print(f"{pr.number} - {pr.title} - {pr.user.login} - {pr.head.ref} - {pr.state}")
# output:
# prs count: 84
# 3028 - Commit verification support - timgates42 - feat/commit_verification - open
# 3022 - add support for generate_release_notes - mball-agathos - issue_2794 - open
# ...
# 1676 - Issue 1655: Add authorize credentials list and removal on organization under SAML - AlexandreODelisle - master - open
# correct head param usage
# will return all open PRs for the specified branch
prs = repository.get_pulls(head=f"{org}:{pr_head_ref}")
print(f"prs count: {prs.totalCount}")
for pr in prs:
print(f"{pr.number} - {pr.title} - {pr.user.login} - {pr.head.ref} - {pr.state}")
# output:
# prs count: 1
# 2929 - Fix requesting urls containing parameters with parameters dict - EnricoMi - pagination-per-page - open
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels