Last active
July 22, 2025 06:19
-
-
Save elemongw/fea09b94b2395b15970b3ed2095c38b3 to your computer and use it in GitHub Desktop.
Find most active forks of a project in GitHub. Sorts by most recently pushed
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| Collect all forks of a github project and return the most recently pushed. | |
| Any alternatives I could find searched only the most recent forks of a project, | |
| which does not return accurate results for projects with many forks. | |
| Note that the GitHub API has a rate limit of 60 requests per hour for unauthenticated requests. | |
| You can create a personal access token in order to circumvent this, which will raise the limit | |
| to 5000 requests per hour. This will be enough even for the biggest projects on GitHub. | |
| This code is licensed under the Public Domain | |
| """ | |
| import requests | |
| from sys import argv, exit | |
| BASE_API_URI = "https://api.github.com" | |
| def collect_pages(repo): | |
| parameters = {"per_page": 100} | |
| response = requests.get( | |
| "/".join((BASE_API_URI, "repos", repo, "forks")), parameters | |
| ) | |
| response.raise_for_status() | |
| data = response.json() | |
| while "next" in response.links: | |
| response = requests.get(response.links["next"]["url"]) | |
| response.raise_for_status() | |
| data.extend(response.json()) | |
| return data | |
| def recently_pushed(data): | |
| forks = {} | |
| for fork in data: | |
| forks[fork["pushed_at"]] = fork["html_url"] | |
| return forks | |
| if __name__ == "__main__": | |
| if not len(argv) == 2: | |
| exit("Usage: find_active_fork.py username/repo") | |
| forks = recently_pushed(collect_pages(argv[1])) | |
| for fork in sorted(forks): | |
| date = fork.replace("T", " (").replace("Z", " UTC)") | |
| print(f"{date}: {forks[fork]}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not https://manpages.ubuntu.com/manpages/focal/man8/forkstat.8.html