有没有办法获取git仓库的下载/克隆统计数据?

zxlwwiss  于 2022-12-28  发布在  Git
关注(0)|答案(6)|浏览(366)

有没有办法知道一个git仓库被克隆或从github下载了多少次?我只是好奇,因为我发现其他的统计数据,比如代码行的提交次数,可以使用以下方法生成:http://gitstats.sourceforge.net/,但我没有找到如何检查克隆/下载计数。

hts6caw3

hts6caw31#

它现在超级容易!
转到“REPO -〉见解-〉流量”

lymnna71

lymnna712#

克隆是一个只读操作,原始存储库不会被修改。您无法提取未被跟踪的数据的统计信息。

ef1yzkbh

ef1yzkbh3#

我刚刚发现有一种更简单的方法可以使用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

玩得开心。

ipakzgxi

ipakzgxi4#

关于下载统计信息,您可以获得有关Releases via the API的信息。
对于那些使用WordPress,我开发了这个插件:* * GitHub Release Downloads**。它允许你获得GitHub仓库版本的下载计数、链接和更多信息。
为了解决最初的问题,简码[grd_count user="User" repo="MyRepo"]将返回一个仓库的下载次数,这个数字对应于一个GitHub仓库的所有版本的所有下载计数值的总和。
示例:

liwlm1x9

liwlm1x95#

实际的克隆计数可以通过Clone Graphs特性获得,我已经能够抓取它来获得单个计数:

#!/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'
50few1ms

50few1ms6#

你可以使用shields.io,它提供了一些图标栏来显示各种网站上的项目数量,包括Github,它们显示下载数量,但不显示克隆数量。
下面是我的一个项目的例子:

降价代码:

![GitHub All Releases](https://img.shields.io/github/downloads/lewdev/hw-gen/total)

结果:

没有人下载我的应用程序,因为它已经发布了,但人们克隆它。所以我宁愿看到计数。

相关问题