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

Examples

Showing the pace at which TypeScript is replacing JavaScript in mattermost-webapp:

% cd ~/src/mattermost-webapp
% git-repo-language-trends --min-interval-days 30 --max-commits 25 --relative .ts+.tsx .js+.jsx

mattermost-webapp language trends

Showing how the implementation of CPython has grown over the last decades in terms of number of lines of C (.c and .h files) and Python (.py files):

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

CPython language trends

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.

It is easy to come up with something more fancy, but it would be overkill.

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

Make an editable install:

python3 -m pip install -e .

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

flake8 && pytest -vv

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.5.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

git_repo_language_trends-0.0.5-py3-none-any.whl (14.0 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