Package: git-repo-language-trends
git-repo-language-trendsAnalyze 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 valuesExamplesShowing the pace at whichKotlinis replacingJavainAndroidXsupportlibraryby
language usage percentage:% cd ~/src/androidx
% git-repo-language-trends --relative --max-commits 30 --min-interval-days 60  .kt .java
% open androidx-language-trends.pngShowing 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
% open cpython-language-trends.pngShowing the pace at whichTypeScriptis replacingJavaScriptinmattermost-webappby
language usage percentage:% cd ~/src/mattermost-webapp
% git-repo-language-trends --min-interval-days 30 --max-commits 25 --relative .ts+.tsx .js+.jsx
% open mattermost-webapp-language-trends.pngShowing line count trends forSwift,Objective-C(.m and .h files summed
together), andMarkdown(.md) in theiOSChartslibrary:% cd ~/src/Charts
% git-repo-language-trends  --min-interval-days 60 .swift .m+.h .md
% open Charts-language-trends.pngSame data as above, but as a comma-separated values (.csv) file, in case you
want to generate plots yourself from the raw data, and limited to 10 commits:% cd ~/src/Charts
% git-repo-language-trends  --max-commits 10 --min-interval-days 60 .swift .m+.h .md -o charts-language-trends.csv
% cat charts-language-trends.csv
        ,.swift,.m+.h,.md
2019-03-20,32163,6205,3785
2019-06-10,32347,6205,3859
2019-09-09,32368,6205,3859
2019-11-13,32746,6205,4007
2020-02-13,32687,6205,4015
2020-04-16,32778,6205,891
2020-07-08,32781,6205,897
2020-10-08,32785,6205,4215
2020-12-15,32176,6219,4225
2021-02-26,31771,6219,4252InstallationRequirements:Python 3.6or laterpip 19.0or laterWhen in doubt, begin by upgradingpip:python3 -m pip install --upgrade pipThen install withpython3 -m pip install git-repo-language-trendsUsageFirst go to the git repository for a project.cd ~/src/your-projectThen run the tool, passing the file extensions for the languages you are
interested in as positional arguments:git-repo-language-trends .java .ktFor 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 .rsIf you want relative numbers, enable the--relativeoption:git-repo-language-trends --relative .c+.h .rsUsegit-repo-language-trends --helpto see more options.Ifgit-repo-language-trendsis not in yourPATHafter installation you can
run the tool via its module, e.g.:python3 -m git_repo_language_trends --helpMethodProgramming 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.PerformanceThis program is pretty fast, because it uses thepygit2wrapper for the C librarylibgit2. It easily counts hundreds of
thousands lines per second on low-end machines. It also uses a cache keyed
by git blob ID to avoid counting lines for the same blob twice.DevelopmentClone this repo:git clone https://github.com/Enselic/git-repo-language-trends.gitCreate a venv:python3 -m venv ~/venv-grlt
source ~/venv-grlt/bin/activateInstall and update dev dependencies:python3 -m pip install --upgrade pip flake8 pytestMake an editable install:python3 -m pip install -e .then make your changes. When done, lint and test:flake8 && pytest -vv