【问题标题】:Is there a way to see a count of all contributions made to Github by me?有没有办法查看我对 Github 所做的所有贡献的计数?
【发布时间】:2015-10-14 01:43:39
【问题描述】:

日历显示去年的捐款。有没有办法查看类似的计数但没有开始日期限制?

【问题讨论】:

标签: github


【解决方案1】:

有没有办法查看类似的计数但没有开始日期限制?

没有,但我构建了git-stats——一个跟踪本地提交和显示图表的工具,就像 GitHub 所做的那样。

我的图表示例。

【讨论】:

    【解决方案2】:

    您可以使用 Github API 检索您的存储库的统计信息,并使用几行代码来生成全局计数。

    注意:公共访问请求的限制非常低。我建议您生成具有Access commit statusRead all user profile data 权限的令牌(Settings > Developper settings > Personal access tokens)。

    这是一个使用 curljq 的小型 bash 脚本。您只需要更改您的用户名。您还可以取消注释 AUTH 行并设置生成的令牌以避免达到查询限制:

    #!/bin/bash
    
    # Parameters
    USER=jyvet
    #AUTH="-u $USER:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
    GAPI="https://api.github.com"
    REPOS=$(curl $AUTH -s $GAPI/users/$USER/repos | jq -c -r '.[].name')
    
    COMMITS=0
    ADDITIONS=0
    DELETIONS=0
    
    # Iterate over all the repositories owned by the user
    for r in $REPOS; do
        STATS=$(curl $AUTH -s "$GAPI/repos/$USER/$r/stats/contributors" |
                jq ".[] | select(.author.login == \"$USER\")" 2> /dev/null)
    
        if [ $? -eq 0 ]; then
            tmp=$(echo -n "$STATS" | jq '.total' 2> /dev/null)
            COMMITS=$(( COMMITS + tmp ))
    
            tmp=$(echo -n "$STATS" | jq '[.weeks[].a] | add' 2> /dev/null)
            ADDITIONS=$(( ADDITIONS + tmp ))
    
            tmp=$(echo -n "$STATS" | jq '[.weeks[].d] | add' 2> /dev/null)
            DELETIONS=$(( DELETIONS + tmp ))
        fi
    done
    
    echo "Commits: $COMMITS, Additions: $ADDITIONS, Deletions: $DELETIONS"
    

    结果:

    > Commits: 193, Additions: 20403, Deletions: 2687
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-28
      • 2014-10-14
      • 1970-01-01
      • 2016-02-28
      • 2015-08-30
      • 2011-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多