有一种方法可以根据搜索批量归档 GitHub 个存储库吗?
There is a way to batch archive GitHub repositories based off of a search?
从 到一个相关问题,我知道可以根据 GitHub 搜索结果批量克隆存储库:
# cheating knowing we currently have 9 pages
for i in {1..9}
do
curl "https://api.github.com/search/repositories?q=blazor+language:C%23&per_page=100&page=$i" \
| jq -r '.items[].ssh_url' >> urls.txt
done
cat urls.txt | xargs -P8 -L1 git clone
我也知道Hub client allows me to make API calls。
hub api [-it] [-X METHOD] [-H HEADER] [--cache TTL] ENDPOINT [-F FIELD|--input FILE]
我想最后一步是,如何使用 Hub 归档存储库?
您可以使用 Update a Repository API 调用更新存储库。
我按以下方式将所有存储库放入 TMP
变量中,运行 如下:
echo $TMP | xargs -P8 -L1 hub api -X PATCH -F archived=true
这里是 $TMP
变量的示例:
echo $TMP
/repos/amingilani/9bot
/repos/amingilani/advent-of-code-2019
/repos/amingilani/alan
/repos/amingilani/annotate_models
从
# cheating knowing we currently have 9 pages
for i in {1..9}
do
curl "https://api.github.com/search/repositories?q=blazor+language:C%23&per_page=100&page=$i" \
| jq -r '.items[].ssh_url' >> urls.txt
done
cat urls.txt | xargs -P8 -L1 git clone
我也知道Hub client allows me to make API calls。
hub api [-it] [-X METHOD] [-H HEADER] [--cache TTL] ENDPOINT [-F FIELD|--input FILE]
我想最后一步是,如何使用 Hub 归档存储库?
您可以使用 Update a Repository API 调用更新存储库。
我按以下方式将所有存储库放入 TMP
变量中,运行 如下:
echo $TMP | xargs -P8 -L1 hub api -X PATCH -F archived=true
这里是 $TMP
变量的示例:
echo $TMP
/repos/amingilani/9bot
/repos/amingilani/advent-of-code-2019
/repos/amingilani/alan
/repos/amingilani/annotate_models