github cli工具gh的使用

1
2
3
4
5
6
7
brew install gh 安装的可能有问题

直接下载二进制
# https://github.com/cli/cli?tab=readme-ov-file#installation


gh search repos 想搜索的关键字 --limit 100 --language=go --json id,name,isArchived,isDisabled,isFork,isPrivate,language,openIssuesCount,stargazersCount,updatedAt,createdAt,defaultBranch,forksCount,description,fullName,hasIssues,fullName,license,owner,size,watchersCount,url --jq '.[]'

gh search repos go(这个是关键字) –limit 100 –language=go



可以加 –json,后面可以是

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
createdAt
defaultBranch
description
forksCount
fullName
hasDownloads
hasIssues
hasPages
hasProjects
hasWiki
homepage
id
isArchived
isDisabled
isFork
isPrivate
language
license
name
openIssuesCount
owner
pushedAt
size
stargazersCount
updatedAt
url
visibility
watchersCount

之一

其实最后更新时间很重要,很多几个月甚至几年没更新的,直接忽略

其实也可以不加关键字~ 这样就是满足是go语言开发的的全部仓库, 但这样只能搜到前1000?

加上各种关键字,能搜到各种关键字条件下的前1000,肯定会有交集/重复,再去一下重就行了~

gh search repos go –limit 100 –language=go –json id,name,isArchived,isDisabled,language,openIssuesCount,stargazersCount,updatedAt,createdAt,defaultBranch,forksCount,description,fullName,size,watchersCount,url,pushedAt –jq ‘.[]’

https://cli.github.com/manual/gh

https://cli.github.com/manual/gh_release_download



关于 updatedAt 和 pushedAt

{
“pushedAt”: “仓库最后一次 git push 操作的时间(代码提交时间)”,
“updatedAt”: “仓库最后一次发生任何更新的时间(包括非代码变更)”
}

但感觉

pushedAt看起来像是上次活动时间,比如有issue等被创建啥的??

要判断这两个时间,都小于3个月才处理,否则算了

gh search repos $1 –limit 100 –language=go –pushed:>$(date -d ‘3 months ago’ +%Y-%m-%d) –stars:>15 –json id,name,isArchived,isDisabled,isFork,isPrivate,language,openIssuesCount,stargazersCount,updatedAt,createdAt,defaultBranch,forksCount,description,fullName,hasIssues,license,owner,size,watchersCount,url,pushedAt –jq ‘.[]’

gh合法的参数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Usage:  gh search repos [<query>] [flags]

Flags:
--archived Filter based on the repository archived state {true|false}
--created date Filter based on created at date
--followers number Filter based on number of followers
--forks number Filter on number of forks
--good-first-issues number Filter on number of issues with the 'good first issue' label
--help-wanted-issues number Filter on number of issues with the 'help wanted' label
--include-forks string Include forks in fetched repositories: {false|true|only}
-q, --jq expression Filter JSON output using a jq expression
--json fields Output JSON with the specified fields
--language string Filter based on the coding language
--license strings Filter based on license type
-L, --limit int Maximum number of repositories to fetch (default 30)
--match strings Restrict search to specific field of repository: {name|description|readme}
--number-topics number Filter on number of topics
--order string Order of repositories returned, ignored unless '--sort' flag is specified: {asc|desc} (default "desc")
--owner strings Filter on owner
--size string Filter on a size range, in kilobytes
--sort string Sort fetched repositories: {forks|help-wanted-issues|stars|updated} (default "best-match")
--stars number Filter on number of stars
-t, --template string Format JSON output using a Go template; see "gh help formatting"
--topic strings Filter on topic
--updated date Filter on last updated at date
--visibility strings Filter based on visibility: {public|private|internal}
-w, --web Open the search query in the web browser

要用updated

gh search repos web3 –limit 100 –language=go
–updated:>$(date -v-3m +%Y-%m-%d)
–stars:>15

更新时间大于3个月前的时间点(即最近三个月内有更新)

gh search repos web3 –limit 100 –language=go –stars “>15” –updated “>$(date -v-3m +%Y-%m-%d)”

文章目录