Which Git commit stats are easy to pull

前端 未结 13 1767
面向向阳花
面向向阳花 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:42

    Thanks to hacker for answering this question. However, I found these modified versions to be better for my particular usage:

    git log --pretty=format:%an \
    | awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'\
    | sort -r
    

    (using awk as I don't have gawk on my mac, and sorting with most active comitter on top.) It outputs a list like so:

     1205 therikss
     1026 lsteinth
      771 kmoes
      720 minielse
      507 pagerbak
      269 anjohans
      205 mfoldbje
      188 nstrandb
      133 pmoller
       58 jronn
       10 madjense
        3 nlindhol
        2 shartvig
        2 THERIKSS
    
    0 讨论(0)
  • 2020-12-12 11:42

    If you are using github, PR Count is a github app built for showing contribution stats.

    0 讨论(0)
  • 2020-12-12 11:45

    First, you don't have to pull anything (as in network pull), because you have the whole repository and the whole history locally. I'm pretty sure there are tools that will give you statistics, but sometimes you can just be creative with the command lines. For instance, this (just out of my head) will give you the number of commits per user:

    git log --pretty=format:%ae \
    | gawk -- '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'
    

    Other statistics you asked for may need more thought put into it. You may want to see the tools available. Googling for git statistics points to the GitStats tool, which I have no experience with and even less idea of what it takes to get it run on windows, but you can try.

    0 讨论(0)
  • 2020-12-12 11:46

    Actually, git already has a command for this:

    git shortlog
    

    in your case, it sounds like you're interested in this form:

    git shortlog -sne
    

    See the --help for various options.

    You may also be interested in the GitStats project. They have a few examples, including the stats for the Git project. From the GitStat main page:

    Here is a list of some statistics generated currently:

    • General statistics: total files, lines, commits, authors.
    • Activity: commits by hour of day, day of week, hour of week, month of year, year and month, and year.
    • Authors: list of authors (name, commits (%), first commit date, last commit date, age), author of month, author of year.
    • Files: file count by date, extensions
    • Lines: Lines of Code by date
    0 讨论(0)
  • 2020-12-12 11:46

    DataHero now makes it easy to pull in Github data and get stats. We use it internally to track our progress on each milestone.

    https://datahero.com/partners/github/

    How we use it internally: https://datahero.com/blog/2013/08/13/managing-github-projects-with-datahero/

    Disclosure: I work for DataHero

    0 讨论(0)
  • 2020-12-12 11:47

    Modify https://stackoverflow.com/a/18797915/3243930 . the output is much closed to the graph data of github.

    #!/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("\t")
      next if parts.size == 0
      if parts[0].match(/[a-zA-Z]+|[^\u0000-\u007F]+/)
        if who
          map[who][0] += memo[0]
          map[who][1] += memo[1]
          if memo[0] > 0 || memo[1] > 0 
            map[who][2] += 1
          end
        end
        who = parts[0]
        memo = [0,0]
        next
      end
      if who
        memo[0]+=parts[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)
提交回复
热议问题