Skip to main content

Plots programming language usage over time in a git repository to an SVG file.

Project description

git-repo-language-trends

Analyze programming language usage over time in a git repository and produce a graphical or textual representation of the result.

Available output file formats:

  • .svg - Scalable Vector Graphics
  • .png - Portable Network Graphics
  • .csv - Comma-separated values
  • .tsv - Tab-separated values

Example command and its SVG output:

% cd ~/src/cpython
% git-repo-language-trends --max-commits 30 --min-interval-days 365 .c+.h .py

CPython, C vs Python, 1992-2021

Installation

Requirements:

  • Python 3.6 or later
  • pip 19.0 or later

When in doubt, begin by upgrading pip:

python3 -m pip install --upgrade pip

Then install with

python3 -m pip install git-repo-language-trends

Usage

First go to the git repository for a project.

cd ~/src/your-project

Then run the tool, passing the file extensions for the languages you are interested in as positional arguments:

git-repo-language-trends .java .kt

For languages with multiple file extensions such as C, you can use the + syntax which will automatically summarize line counts from both file extensions. To compare C and Rust:

git-repo-language-trends .c+.h .rs

If you want relative numbers, enable the --relative option:

git-repo-language-trends --relative .c+.h .rs

Use git-repo-language-trends --help to see more options.

If git-repo-language-trends is not in your PATH after installation you can run the tool via its module, e.g.:

python3 -m git_repo_language_trends --help

Method

Programming langauge usage is determined by the total number of newline characters in files with a given file extension.

Performance

This program is pretty fast, because it uses the pygit2 wrapper for the C library libgit2. On my low-end computer* it counts ~400 000 lines per second.

*with an Intel® Celeron® J4005 CPU @ 2.00GHz

Development

Clone this repo:

git clone https://github.com/Enselic/git-repo-language-trends.git

Create a venv:

python3 -m venv ~/venv-grlt
source ~/venv-grlt/bin/activate

Install and update dev dependencies:

python3 -m pip install --upgrade pip flake8 pytest build twine

Make an editable install:

python3 -m pip install -e .

then make your changes. When done, lint and test:

flake8 && pytest -vv

TODO

  • limit size of cache
  • Add .tsv and .csv and .png and .svg CLI test cases
  • More examples, make image links work on pip repo too

Features not yet implemeneted

  • Support import of .tsv or .csv data to support generating e.g. a PNG without re-reunning analysis
  • More short options
  • Support -o args multiple times
  • Warn before overwrite existing file

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git-repo-language-trends-0.0.4.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

git_repo_language_trends-0.0.4-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page