Skip to content

peterwilliams97/git-stats

Repository files navigation

Compute and display statistics of git repositories

Requirements

A scientific Python distribution such as Anaconda.

e.g. Install Anaconda then conda update conda conda update anaconda conda install Pygments

Tested with

python    : 2.7.10 and 3.5.1
numpy     : 1.10.2
matplotlib: 1.5.0
pandas    : 0.17.1
pygments  : 2.0.2

You can check your versions with version.py.

git-stats currently contains only one analysis script, code-age.py.

Usage

  • Copy code-age.py to your computer
  • Open a shell and cd to the root of the git repository you want to report
  • python code-age.py NOTE: This can take hours to run a big repository as it blames every file in the repository.
  • The location of the reports directory will be written to stdout
  • Optionally try some patterns e.g. python code-age.py '*.py', python code-age.py docs

Reports

code-age.py analyzes the age of files in a git repository and writes some reports and draws some graphs about them. It writes reports in the directory structure given in git.stats.tree.txt

NOTE: LoC is short for Lines of Code.

e.g. For repository git, which is a github mirror off the git source code:

[root]                                    Defaults to ~/git.stats
  └── git                                 Directory for https://github.com/git/git.git
      └── reports
          └── 2015-12-29.28274d02.master  Revision 28274d02 which was created on 2015-12-22 on
              │                           on branch "master".
              └── [all-files]             Report on all files in this revision
                  ├── README              Summary of files in [all-files]
                  ├── author_ext_files.csv Number of files of given extension in which author has code
                  ├── author_ext_loc.csv  Number of LoC author in files of given extension by author
                  ├── [all-authors]       Sub-report on all authors
                  │   ├── README          Summary of files in [all-authors]
                  │   ├── code-age.png    Graph of code age. LoC / day vs date
                  │   ├── code-age.txt    List of commits in the peaks in the code-age.png graph
                  │   ├── details.csv     LoC in each directory in for these files and authors
                  │   ├── newest-commits.txt List of newest commits for these files and authors
                  │   └── oldest-commits.txt List of oldeswest commits for these files and authors
            ....
                  ├── Alex_Henrie         Sub-report on author Alex Henrie
                  │   ├── README
                  │   ├── code-age.png
                  │   ├── code-age.txt
                  │   ├── details.csv
                  │   ├── newest.txt
                  │   └── oldest.txt

This file contains summary information about this report.

Summary of File Counts and LoC by Author and File Extension
===========================================================

Totals: 2806 files, 23743 commits, 764802 LoC

Revision Details
----------------
Repository:  git (https://github.com/git/git.git)
Date:        2015-12-29
Description: master
SHA-1 hash   28274d02c489f4c7e68153056e9061a46f62d7a0

This shows the number of files in which each author has one or more lines of code in the revision by extension and author. being reported. (This table shown on this page is truncated. author_ext_files.csv has the full table.)

NOTE: The numbers of files in the Total row and column are not the number of files in the repository. They are the total numbers of files in which each author has one or more lines of code.

Total.c.sh.txt.h
Total40742.014352.09457.07276.02710.0
Junio C Hamano7747.0277917131973504
Jeff King3070.01479853296291
Nguyễn Thái Ngọc Duy1680.0994226174210
Shawn O. Pearce1254.03843529955
Jonathan Nieder1159.030037330562
Linus Torvalds1088.07707816136
Johannes Schindelin1022.045829810392
René Scharfe761.05141046073
Michael Haggerty707.04371065670
Thomas Rast696.017115119334

This shows the lines of code in the revision being reported by extension and author. (The table shown on this page is truncated. author_ext_loc.csv has the full table.)

Total.c.sh.po.txt
Total764802.0198828.0172727.0159684.081591.0
Junio C Hamano115080.03743327753622028929
Jeff King31776.0131341172403175
Jiang Xin24649.011707181125681
Shawn O. Pearce24636.05392474815192353
Nguyễn Thái Ngọc Duy20908.013226549901233
Peter Krefting16243.0411157180
Alexander Shopov16182.0001614929
Johannes Schindelin15963.07531499601345
Jonathan Nieder15266.03111662501914
Ævar Arnfjörð Bjarmason14688.011093130693107

This directory contains files that report on the age of all authors code for all files (i.e. every file) in revision 28274d02, the git repository master branch on 2015-12-29.

1) code-age.png is a graph showing the age of the code in question.

The horizontal axis is date and the vertical axis is LoC /day. This means the area under the curve between two dates is the LoC surviving from the period bounded by those datess.

You can see that some code from 2006 survives in the current git master branch.

Age graph

2) code-age.txt lists the commits in the peaks in code-age.png
================================================================================
[all-authors]: 10 peaks 117654 LoC
................................................................................
  5) 187 commits 12253 LoC around 2007-07-18
 1025 LoC, 2007-07-21 90a7149 German translation for git-gui
 1006 LoC, 2007-07-22 e79bbfe Add po/git-gui.pot
  992 LoC, 2007-07-22 4fe7626 Italian translation of git-gui
 1095 LoC, 2007-07-25 2340a74 Japanese translation of git-gui
 1150 LoC, 2007-07-27 f6b7de2 Hungarian translation of git-gui
................................................................................
 10) 130 commits 9705 LoC around 2009-06-03
  135 LoC, 2009-05-26 3902985 t5500: Modernize test style
 7040 LoC, 2009-06-01 f0ed822 Add custom memory allocator to MinGW and MacOS builds
  124 LoC, 2009-06-04 195643f Add 'git svn reset' to unwind 'git svn fetch'
  127 LoC, 2009-06-06 2264dfa http*: add helper methods for fetching packs
  288 LoC, 2009-06-06 5424bc5 http*: add helper methods for fetching objects (loose)
................................................................................
    ...
3) oldest-commits.txt lists the oldest commits in the code in question.
================================================================================
[all-authors]: 23743 commits 764802 LoC
................................................................................
111 LoC, 2005-04-08 e83c516 Initial revision of "git", the information manager from hell
 38 LoC,   cache.h
 22 LoC,   read-cache.c
 11 LoC,   README
................................................................................
 40 LoC, 2005-04-08 8bc9a0c Add copyright notices.
  5 LoC,   builtin/cat-file.c
  5 LoC,   builtin/commit-tree.c
  5 LoC,   builtin/diff-files.c

    ...
4) newest-commits.txt lists the oldest commits in the code in question.
================================================================================
[all-authors]: 23743 commits 764802 LoC
................................................................................
   12 LoC, 2015-12-29 28274d0 Git 2.7-rc3
   11 LoC,   Documentation/RelNotes/2.7.0.txt
    1 LoC,   GIT-VERSION-GEN
................................................................................
  119 LoC, 2015-12-28 c5e5e68 l10n: Updated Bulgarian translation of git (2477t,0f,0u)
  119 LoC,   po/bg.po
................................................................................

   ...
5) details.csv attempts to show where the code is distributed through the source tree.
dirLoCfrac
7648021
t1679550.21960585877128982
po1207870.15793237988394382
Documentation826410.1080554182651196
builtin559580.07316664966880317
git-gui539340.0705202130747566
git-gui/po370870.6876367412022101
contrib358900.04692717853771303
gitk-git293850.03842170914825013
compat258840.03384405375508955
Documentation/RelNotes197090.2384893696833291

About

Compute statistics on git repositories

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages