有没有办法获取从Github克隆或下载Git存储库的次数?我只是好奇,因为我发现可以使用http://gitstats.sourceforge.net/生成其他统计信息,比如提交次数和代码行数,但我没有找到如何检查克隆/下载计数。
有没有办法获取从Github克隆或下载Git存储库的次数?我只是好奇,因为我发现可以使用http://gitstats.sourceforge.net/生成其他统计信息,比如提交次数和代码行数,但我没有找到如何检查克隆/下载计数。
克隆是只读操作,原始代码库不会被修改。无法获取未跟踪数据的统计信息。
github.com
服务的 dom,至少在没有私有 token 的情况下仍然无法访问。请参见此处的详细信息:https://github.com/MShawon/github-clone-count-badge - Andry我刚刚发现使用GitHub API可以用一个命令更简单地获得它。
curl -u [username]:[password] https://api.github.com/repos/[owner]/[repo]/traffic/clones
这里:
username = your github id
password = your github password, optional. If not put in command, a password request would pop out.
owner = the owner of the repo, might be another name for a organized repo
repo = the repo name
玩得开心。
"documentation_url": "https://docs.github.com/rest/reference/repos#get-repository-clones"
- SuperCode[grd_count user="User" repo="MyRepo"]
将返回存储库的下载次数。这个数字对应于所有GitHub存储库的所有发行版下载计数值的总和。![GitHub All Releases](https://img.shields.io/github/downloads/lewdev/hw-gen/total)
结果:
因为我的应用程序已经发布,所以没有人“下载”它,但人们会克隆它。所以我更想看到这方面的统计数据。
#!/bin/sh
#
# This script requires:
# apt-get install html-xml-utils
# apt-get install jq
#
USERNAME=dougluce
PASSWORD="PASSWORD GOES HERE, BE CAREFUL!"
REPO="dougluce/node-autovivify"
TOKEN=`curl https://github.com/login -s -c /tmp/cookies.txt | \
hxnormalize | \
hxselect 'input[name=authenticity_token]' 2>/dev/null | \
perl -lne 'print $1 if /value=\"(\S+)\"/'`
curl -X POST https://github.com/session \
-s -b /tmp/cookies.txt -c /tmp/cookies2.txt \
--data-urlencode commit="Sign in" \
--data-urlencode authenticity_token="$TOKEN" \
--data-urlencode login="$USERNAME" \
--data-urlencode password="$PASSWORD" > /dev/null
curl "https://github.com/$REPO/graphs/clone-activity-data" \
-s -b /tmp/cookies2.txt \
-H "x-requested-with: XMLHttpRequest" #| jq '.summary'