Skip to content

Git Log Parser

Category: Parser (takes in git-log file (or git repository) and generates cc.json)

This parser generates visualisation data from a git repository log and a repository files list or direct access to a git repository.

This parser specializes in tracking file changes across different file-versions on different feature-branches and then the merged main. Furthermore, special care is taken not to display non-existent files that might show up in normal Git histories due to renaming actions on feature branches. Note that file deletions that get reverted later on are ignored by this parser.

MetricDescription
age_in_weeksThe file’s age measured in weeks since creation.
number_of_authorsThe count of distinct authors (including co-authors) who have contributed commits.
number_of_commitsThe total commits made to the file.
number_of_renamesHow many times the file has been renamed.
range_of_weeks_with_commitsThe span of weeks during which commits were made.
successive_weeks_with_commitsConsecutive weeks during which the file received commits.
weeks_with_commitsThe number of weeks in which the file was modified.
highly_coupled_filesFiles often modified together with this file (35% overlap or more).
median_coupled_filesThe median number of files modified in tandem with this file.
feat_commitsNumber of commits starting with ‘feat’ for this file.
fix_commitsNumber of commits starting with ‘fix’ for this file.
docs_commitsNumber of commits starting with ‘docs’ for this file.
style_commitsNumber of commits starting with ‘style’ for this file.
refactor_commitsNumber of commits starting with ‘refactor’ for this file.
test_commitsNumber of commits starting with ‘test’ for this file.
hotfix_commitsNumber of commits containing the word ‘hotfix’ for this file.
hotfix_commit_ratioRatio of hotfix commits (containing the ‘hotfix’ keyword) to total commits for this file.
semantic_commit_ratioRatio of semantic commits (which start with feat, fix, docs, style, refactor or test) to total commits for this file.

Additionally, the following Edge Metrics are calculated:

MetricDescription
temporal_couplingThe degree of temporal coupling between two files (>=35%)

The names of authors are saved when the --add-author flag is set.

As this parser can generate metrics based on a given git-log file or given a git repository (where the git-log is then generated on the fly), some parameters are only available in the log-scan mode or the repo-scan mode.

ParametersDescription
log-scanuse log-scan mode - generates cc.json from a given git-log file
repo-scanuse repo-scan mode - generates cc.json from an automatically generated git-log file
--add-authoradd an array of authors to every file
--commit=<ref>analyze the repository at a specific git commit, tag, branch, or date expression (creates a temporary worktree, repo-scan only). See Commit-Based Analysis
--git-log=FILEgit-log file to parse (only available for log-scan mode!)
-h, --helpdisplays help and exits
-nc, --not-compressedsave uncompressed output File
-o, --output-file=<outputFilePath>output File (or empty for stdout)
--repo-files=FILE list of all file names in current git project (only available for log-scan mode!)
--repo-path=DIRECTORYroot directory of the repository (only available for repo-scan mode!)
--silentsuppress command line output during process
Usage:
ccsh gitlogparser [-h] [COMMAND]
Usage for log-scan mode:
ccsh gitlogparser log-scan [-h] [--add-author] [-nc] [--silent]
--git-log=FILE [-o=<outputFilePath>]
--repo-files=FILE
Usage for repo-scan mode:
ccsh gitlogparser repo-scan [-h] [--add-author] [--commit=<ref>] [-nc]
[--silent] [-o=<outputFilePath>]
[--repo-path=DIRECTORY]

Scan a local git repository on your machine

Section titled “Scan a local git repository on your machine”

Creating required files on the fly with repo-scan

Section titled “Creating required files on the fly with repo-scan”

See ccsh gitlogparser repo-scan -h for help. Standard usage:

ccsh gitlogparser repo-scan --repo-path <path>

With the sub command repo-scan you can parse a local git repository on your disk. During scanning a git log of the repository in the current working directory (or from the directory specified by repo-path) is created in your temp-Folder and parsed automatically. Furthermore, the parser creates another temporary file-name-list of files that are tracked by git automatically which is needed for the parsing process.

The result is written as JSON to standard out or into an output file (if specified by -o option).

If a project is piped into the GitLogParser, the results and the piped project are merged. The resulting project has the project name specified for the GitLogParser.

  • ccsh gitlogparser repo-scan --repo-path <path_to_my_git_project> -o output.cc.json.gz
  • load output.cc.json.gz in visualization

Manual creation of required files with log-scan

Section titled “Manual creation of required files with log-scan”

See ccsh gitlogparser log-scan -h for help. Standard usage:

ccsh gitlogparser log-scan --git-log <path> --repo-files <path>

With the sub command log-scan, an existing git log and file name list are used for parsing.

The result is written as JSON to standard out or into an output file (if specified by -o option).

If a project is piped into the GitLogParser, the results and the piped project are merged. The resulting project has the project name specified for the GitLogParser.

Creating the repository log for metric generation
Section titled “Creating the repository log for metric generation”
SCMLog formatCommand for log creationtracks renamesignores deleted filessupports code churn
gitGIT_LOG_NUMSTAT_RAW_REVERSEDgit log --numstat --raw --topo-order --reverse -myesyesyes

You can also use the bash script anongit which generates a git log with anonymized authors for usage with CodeCharta.

Creating the git files list of the repository for metric generation
Section titled “Creating the git files list of the repository for metric generation”
git ls-files > file-name-list.txt

Please make sure to execute this command in the root folder of your repository.

cd <my_git_project>
git log --numstat --raw --topo-order --reverse -m > git.log (or anongit > git.log)
git ls-files > file-name-list.txt
ccsh gitlogparser log-scan --git-log git.log --repo-files file-name-list.txt -o output.cc.json.gz

load output.cc.json.gz in visualization