Created
November 10, 2023 13:18
-
-
Save nilsleh/e54ea7ca985989185d32bad542e30686 to your computer and use it in GitHub Desktop.
Retrieve the contributors from a milestone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# Set up authentication with your PAT | |
headers = { | |
'Authorization': 'Bearer YOUR_ACCESS_TOKEN' | |
} | |
# Define the repository information | |
repo_owner = 'repo_owner' | |
repo_name = 'repo_name' | |
milestone_number = '15' # can be found when clicking on a milestone and inspecting the link | |
# Make a request to get the list of issues for the milestone | |
response = requests.get(f'https://api.github.com/repos/{repo_owner}/{repo_name}/issues?milestone={milestone_number}&state=all', headers=headers) | |
# Check if the request was successful (status code 200) | |
if response.status_code == 200: | |
issues = response.json() | |
contributors = set() | |
for issue in issues: | |
# Check if the issue is a pull request | |
if 'pull_request' in issue: | |
contributors.add(issue['user']['login']) | |
for contributor in sorted(contributors): | |
print(f"@{contributor}") | |
else: | |
print(f"Error: Unable to retrieve issues. Status code: {response.status_code}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment