Skip to content

Instantly share code, notes, and snippets.

@aaron-prindle
Created February 13, 2024 03:07
Show Gist options
  • Save aaron-prindle/c1e0d94314effa5cb6a796ea5a75d677 to your computer and use it in GitHub Desktop.
Save aaron-prindle/c1e0d94314effa5cb6a796ea5a75d677 to your computer and use it in GitHub Desktop.
Pyhon script to get all contributors for GoogleContainerTools/kaniko repository
import requests
def get_all_contributors(owner, repo):
contributors = []
per_page = 100 # Max value allowed by GitHub API
page = 1
while True:
url = f"https://api.github.com/repos/{owner}/{repo}/contributors"
params = {'per_page': per_page, 'page': page}
headers = {'Accept': 'application/vnd.github.v3+json'}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
data = response.json()
if data:
contributors.extend(data)
page += 1
else:
break
else:
print(f"Failed to fetch data: {response.status_code}")
break
return contributors
# Replace 'your_token_here' with your actual GitHub Personal Access Token if you hit rate limits
headers = {'Authorization': 'token your_token_here'}
owner = 'GoogleContainerTools'
repo = 'kaniko'
contributors = get_all_contributors(owner, repo)
print(f"Total contributors: {len(contributors)}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment