Reputation: 2787
How can I see a list of all the child repos that have been created from my template repo on GitHub?
GitHub displays how many forks were created from a given repo at the top of the WUI, next to the "stars" and "watches." And you can display a list of links to those users' forks under the "analytics" tab.
How can I get a similar list of all the repos that were created from my template repo on GitHub?
Upvotes: 33
Views: 6447
Reputation: 316
This feature is available on GitHub:
You will now be able to see what projects are using the template. There are filtering options above the results that you can use to refine what's displayed
Upvotes: 1
Reputation: 46470
Here's a "one-liner" using gh
for a specific organization (global search does NOT work):
gh repo list my-org-name \
--limit 1000 \
--json name,templateRepository \
--jq '.[] | select(.templateRepository.name == "my-template-repo-name") | .name'
I guess it's the same solution as https://stackoverflow.com/a/76373786/253468, just using the built-in JQ and a few thousand less API calls without shell scripting.
Upvotes: 2
Reputation: 533
Shell scripting and gh
FTW:
#!/bin/bash
org_name="MYORGNAME"
repo_list=`gh repo list $org_name --limit 1000 | awk '{print $1}'`
template_repo=$1
if [ -z "$template_repo" ]
then
echo "Usage: $0 <template_repo>"
echo " List repositories generated from a given template repository"
echo "ABORTING!"
exit 1
fi
echo "Searching for repositories generated from template: $template_repo"
for repo in $repo_list
do
repo_info=`gh api repos/$repo`
echo "$repo_info" | jq -r ".template_repository.full_name" | grep "$template_repo" 2>&1 > /dev/null
if [ "$?" -eq "0" ]
then
echo "repo_using_template: $repo"
fi
done
Then, run ./find_repo_by_template.sh <template_repo>
to get a listing of repositories that use that template, AFTER setting the org_name
variable. My use case required searching within an organization. If you have a different use case, you should be able to easily tweak my script to get the desired results.
Upvotes: 4
Reputation: 3306
Eureka! After reading this - Search based on the contents of a repository, the answer was clear! Search by README.md file content!
Use GitHub's search engine and provide a unique combination of words that appear in your README.md file. This is how I do it for my template - unfor19/terraform-multienv
in:readme sort:updated -user:unfor19 "tfmultienv"
github.com/search?q=in%3Areadme+sort%3Aupdated+-user%3Aunfor19+%22%60tfmultienv%60%22&type=repositories
To get meaningful search results
sort:updated
-user:USERNAME
with -QUALIFIER.Instead of hardcoding USERNAME
you can use the keyword @me
.
Upvotes: 8