Is there a way to get download/clone statistics of a git repository?

后端 未结 6 915
孤街浪徒
孤街浪徒 2020-12-09 00:42

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

6条回答
  •  醉话见心
    2020-12-09 01:06

    Actual clone counts are available via the Clone Graphs feature, 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 $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'
    

提交回复
热议问题