有没有办法获取 git 存储库的下载/克隆统计信息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6697557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to get download/clone statistics of a git repository?
提问by Shreyas Karnik
Is there any way to get how many times a git repository has been cloned or downloaded from github? I was just curious as I found other statistics such as commit times lines of codes cam be generated using: http://gitstats.sourceforge.net/but I did not find how to check for clone/download count.
有什么方法可以获取 git 存储库被克隆或从 github 下载的次数?我只是很好奇,因为我发现其他统计数据,例如代码行的提交时间可以使用:http: //gitstats.sourceforge.net/生成,但我没有找到如何检查克隆/下载计数。
采纳答案by meagar
Cloning is a read-only operation, the original repository isn't modified. There is no way you can pull statistics for data that simply isn't tracked.
克隆是只读操作,不会修改原始存储库。您无法为根本没有跟踪的数据提取统计信息。
回答by Wei Song
I just find out there is an even simpler way to get it with a single command using the github API.
我只是发现有一种更简单的方法可以使用 github API 通过单个命令来获取它。
curl -u [username]:[password] https://api.github.com/repos/[owner]/[repo]/traffic/clones
here:
这里:
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
Have fun.
玩得开心。
回答by IvanRF
Regarding download statistics, you can get information about your Releases via the API.
For those using WordPress, I developed this plugin: GitHub Release Downloads. It allows you to get the download count, links and more information for releases of GitHub repositories.
对于那些使用 WordPress 的人,我开发了这个插件:GitHub Release Downloads。它允许您获取 GitHub 存储库版本的下载计数、链接和更多信息。
To address the original question, the shortcode [grd_count user="User" repo="MyRepo"]
will return the number of downloads for a repository. This number corresponds to the sum of all download count values of all releases for one GitHub repository.
为了解决最初的问题,短代码[grd_count user="User" repo="MyRepo"]
将返回存储库的下载次数。此数字对应于一个 GitHub 存储库的所有版本的所有下载计数值的总和。
Example:
例子:
回答by Allen Luce
Actual clone counts are available via the Clone Graphsfeature, which I've been able to scrape to get the individual counts:
实际克隆计数可通过克隆图功能获得,我已经能够抓取该功能以获取单个计数:
#!/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 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'