Skip to content

Documentation

Adam Waldenberg edited this page Dec 14, 2015 · 10 revisions

This document covers the features of gitinspector, it's options and how to use them.

Requirements

  • Git executable defined somewhere in your PATH, otherwise gitinspector will not be able to run git.
  • Python 2.6+.

Running gitinspector

The program can be executed using two different methods.

  • By changing directory to a GIT repository and running the command gitinspector.py [OPTION]...
  • By running the command gitinspector.py [OPTION]... [GIT REPOSITORY]

The gitinspector options

The gitinspector script itself accepts a number of options that modifies it's behavior and how statistics are generated. It is possible to get a brief explanation of all available options by supplying -h or --help when running the program. Boolean arguments can only be given to long options.

Below is a table of the available options and their compatibility

Option Availability Description
-c,--checkout-missing[=BOOL] < 0.4.0 By default, gitinspector will just print out missing files in a list and skip the inclusion of certain statistics from those files. With this option, gitinspector will try to checkout any missing files before computing statistics.
-f, --file-types=EXTENSIONS A comma separated list of file extensions to include when computing statistics. The default file extensions used are: java,c,cc,cpp,h,hh,hpp,py,glsl,rb,js,sql.

(New since 0.4.2):
Specifying a single '*' asterisk character includes files with no extension. Specifying two consecutive '**' asterisk characters includes all files regardless of extension.
-F, --format=FORMAT > 0.2.0 Defines in which format output should be generated; the default format is "text" and the available formats are: html,htmlembedded,json,text,xml. Refer to Output Formats section for more information about each format available.
--grading[=BOOL] > 0.2.0 Show statistics and information in a way that is formatted for grading of student project; this is the same as supplying -HlmrTw.
-H, --hard[=BOOL] Track rows and look for duplicates harder. In essence, this passes additional -C (and -M) options to the git executable.
-l, --list-file-types[=BOOL] List all the file extensions available in the current branch of the repository. This can be very useful when you want to check what extensions are available in the repository. These can later be passed to gitinspector using the -f or --file-types options.
-L, --localize-output[=BOOL] > 0.3.0 By default; the generated statistics are always in English. This flag localizes the generated output to the selected system language if a translation is available.
-m, --metrics[=BOOL] Include checks for certain metrics during the analysis of commits. Metrics can be considered in a number of languages. Please refer to Supported languages for more information.
-r, --responsibilities[=BOOL] Show which files the different authors seem most responsible for.
--since=DATE > 0.2.1 Show statistics for commits more recent than a specific date. The date format is in approxidate; the same as the format used in git itself.
-T, --timeline[=BOOL] Show commit timeline, including author names. the timeline shows a statistical analysis where the amount of changes is calculated in relation to all other changes made by all other authors a specific month. Using the -w option, it is possible to get this output specified in weeks instead.
--until=DATE > 0.2.1 Show statistics for commits older than a specific date. The date format is in approxidate; the same as the format used in git itself.
--tda367 < 0.2.0 Show statistics and information in a way that is formatted for the course TDA367/DIT211; this parameter equals -lmrTw.
-w, --weeks[=BOOL] Show all statistical information in weeks instead of in months.
-x, --exclude=PATTERN An exclusion filtering expression describing patterns that should be excluded from the statistics. Works in the same manner as an inverted grep, meaning that any matched expressions will be excluded from the generated statistics. Refer to the Filtering section about possible expressions. Can be specified multiple times. (New since 0.3.0: Support for regular expressions.)
-h, --help Display this help and exit.
--version Output version information and exit.

Supported output formats (new since 0.2.0)

There is support for multiple output formats in gitinspector. An output format can be selected using the -F/--format flags when running the main gitinspector script.

Text (Plain Text)

Plain text with some very simple ANSI formatting, suitable for console output. This is the format chosen by default in gitinspector.

HTML

HTML with external links. The generated HTML page links to some external resources; such as the JavaScript library JQuery. It requires an active Internet connection to properly function. This output format will most likely also link to additional external resources in the future.

HTMLEmbedded (new since 0.3.0)

HTML with no external links. Similar to the HTML output format, but requires no active Internet connection. As a consequence; the generated pages are bigger (as certain scripts have to be embedded into the generated output).

JSON (new on the master branch)

JSON suitable for machine consumption. If you want to parse the output generated by gitinspector in a script or application of your own; this format or the XML format is suitable.

XML

XML suitable for machine consumption. If you want to parse the output generated by gitinspector in a script or application of your own; this format or the JSON format is suitable.

Filtering

Gitinspector offers several different ways of filtering out unwanted information from the generated statistics.

  • gitinspector -x myfile  Filter out and exclude statistics from all files (or paths) with the string "myfile".
  • gitinspector -x file:myfile  Filter out and exclude statistics from all files (or paths) with the string "myfile".
  • gitinspector -x author:John  Filter out and exclude statistics from all authors containing the string "John".
  • gitinspector -x email:@gmail.com  Filter out and exclude statistics from all authors with a gmail account.
  • gitinspector -x revision:8755fb33  Filter out and exclude statistics from all revisions containing the hash "8755fb33".
  • gitinspector -x message:BUGFIX  Filter out and exclude statistics from all revisions containing "BUGFIX" in the commit message.

The gitinspector command also lets you add multiple filtering rules by simply specifying the -x option several times or by separating each filtering rule with a comma;

  • gitinspector -x author:John -x email:@gmail.com
  • gitinspector -x author:John,email:@gmail.com

Sometimes, sub-string matching (as described above) is simply not enough. Therefore, gitinspector let's you specify regular expressions as filtering rules. This makes filtering much more flexible;

  • gitinspector -x "author:^(?!(John Smith))"  Only show statistics from author "John Smith".
  • gitinspector -x "author:^(?!([A-C]))"  Only show statistics from authors starting with the letters "A/B/C".
  • gitinspector -x "email:.com$"  Filter out statistics from all email addresses ending with ".com".

Supported languages

While gitinspector can include any textual data in reports by just specifying file extensions with "-f", it only supports a given number of languages when calculating comments and metrics. As of the current version, these are the currently supported languages and file extensions:

Language Comments Metrics File extensions Included in analysis by default
ADA Yes No ada, adb, ads No
C Yes Yes c, h Yes
C++ Yes Yes cc, h, hh, hpp Yes
C# Yes Yes cs No
GNU Gettext Yes No po, pot No
Haskell Yes No hs No
HTML Yes No html No
Java Yes Yes java Yes
JavaScript Yes Yes js Yes
LaTeX Yes No tex No
OCaml Yes No ml, mli No
OpenGL Shading Language Yes No glsl Yes
Perl Yes No pl No
PHP Yes No php No
Python Yes Yes py Yes
Ruby Yes No rb Yes
Scala Yes No scala No
SQL Yes No sql Yes
XML Yes No xml, jspx No

If you are missing support for a language, patches or pull requests are highly welcome. Adding support for comments or metrics is very easy and briefly described in issue #59.

Using git config to configure gitinspector (new since 0.3.0)

Options in gitinspector can be set using git config. Consequently, it is possible to configure gitinspector behavior globally (in all git repositories) or locally (in a specific git repository). It also means that settings will be permanently stored. All the long options that can be given to gitinspector can also be configured via git config (and take the same arguments).

To configure how gitinspector should behave in all git repositories, execute the following git command:

git config --global inspector.option setting

To configure how gitinspector should behave in a specific git repository, execute the following git command (with the current directory standing inside the repository in question):

git config inspector.option setting

Windows support

If you want to run gitinspector under Windows, there are a few things to consider. Refer to the following page for more information: http://docs.python.org/using/windows.html