Which Git commit stats are easy to pull

前端 未结 13 1768
面向向阳花
面向向阳花 2020-12-12 11:23

Previously I have enjoyed TortoiseSvn\'s ability to generate simple commit stats for a given SVN repository. I wonder what is available in Git and am particularly interested

相关标签:
13条回答
  • 2020-12-12 11:55

    Note that, if your repo is on GitHub, you now (May 2013) have a new set of GitHub API to get interesting statistics.
    See "File CRUD and repository statistics now available in the API"

    That would include:

    • Contributors
    • Commit Activity
    • Code Frequency
    • Participation
    • Punch Card
    0 讨论(0)
  • 2020-12-12 11:57

    Here is a simple ruby script that I used to get author, lines added, lines removed, and commit count from git. It does not cover commits over time.

    Note that I have a trick where it ignores any commit that adds/removes more than 10,000 lines because I assume that this is a code import of some sort, feel free to modify the logic for your needs. You can put the below into a file called gitstats-simple.rb and then run

    git log --numstat --pretty='%an' | ruby gitstats-simple.rb
    

    contents of gitstats-simple.rb

    #!/usr/bin/ruby
    
    # takes the output of this on stdin: git log --numstat --prety='%an'
    
    map = Hash.new{|h,k| h[k] = [0,0,0]}
    who = nil
    memo = nil
    STDIN.read.split("\n").each do |line|
      parts = line.split
      next if parts.size == 0
      if parts[0].match(/[a-z]+/)
        if who && memo[0] + memo[1] < 2000
          map[who][0] += memo[0]
          map[who][1] += memo[1]
          map[who][2] += 1
        end
        who = parts[0]
        memo = [0,0]
        next
      end
      if who
        memo[0]+=line[0].to_i
        memo[1]+=parts[1].to_i
      end
    end
    
    puts map.to_a.map{|x| [x[0], x[1][0], x[1][1], x[1][2]]}.sort_by{|x| -x[1] - x[2]}.map{|x|x.inspect.gsub("[", "").gsub("]","")}.join("\n")
    
    0 讨论(0)
  • 2020-12-12 11:58

    Here are ways to get stats for a specific branch or two hashs.

    key here is the ability to do HASH..HASH

    Below I am using the first hash from a branch to the HEAD which is the end of that branch.

    Show total commits in a branch

    • git log FIRST_HASH..HEAD --pretty=oneline | wc -l
    • Output 53

    Show total commits per author

    • git shortlog FIRST_HASH..HEAD -sne
    • Output
    • 24 Author Name
    • 9 Author Name
    0 讨论(0)
  • 2020-12-12 12:00

    I've written a small shell script that calculates merge statistics (useful when dealing with a feature-branch-based workflow). Here's an example output on a small repository:

    [$]> git merge-stats
    % of Total Merges               Author  # of Merges  % of Commits
                57.14     Daniel Beardsley            4          5.63
                42.85        James Pearson            3         30.00
    
    0 讨论(0)
  • 2020-12-12 12:04

    The best tool so far I identfied is gitinspector. It give the set report per user, per week etc

    You can install like below with npm

    npm install -g gitinspector
    

    Details to get the links are below

    https://www.npmjs.com/package/gitinspector
    https://github.com/ejwa/gitinspector/wiki/Documentation
    https://github.com/ejwa/gitinspector
    

    example commands are

    gitinspector -lmrTw
    gitinspector --since=1-1-2017
    

    etc

    0 讨论(0)
  • 2020-12-12 12:06

    See this gitstat project

    http://mirror.celinuxforum.org/gitstat/

    0 讨论(0)
提交回复
热议问题