CommitService.CommitLanguages implementation with tokei
This introduces a new binary dependency on the [Tokei](https://crates.io/crates/tokei) code statistics tool. The path to the Tokei executable is configurable as `hgitaly.tokei-executable`, defaulting to `tokei`. Strict comparison with Gitaly is not fully possible, as Tokei does not produce the very same results as GitHub Linguist (or `go-enry` which is the library Gitaly is currently moving to). For instance `robots.txt` is detected as the `robots.txt` language by Linguist and as `Plain Text` by tokei. That being said, we can compare more frequent results, namely Python and Ruby. We vendor the `languages.json` file from GitHub Linguist to add the color information (not part of Tokei results), with the same defaulting logic as Gitaly (see the detailed docstrings), based on a hash of the language name. We were lucky to find a programming language (COBOL) to base our tests on. It is important to sort the results in decreasing order, because the Rails app considers only the 5 most frequent languages in the repository, and does so by truncating at the 5 first elements.
parent
2acf3e5f
No related branches found
No related tags found
Showing
- hgext3rd/hgitaly/__init__.py 8 additions, 0 deletionshgext3rd/hgitaly/__init__.py
- hgitaly/linguist/__init__.py 132 additions, 0 deletionshgitaly/linguist/__init__.py
- hgitaly/linguist/languages.json 1 addition, 0 deletionshgitaly/linguist/languages.json
- hgitaly/service/commit.py 27 additions, 1 deletionhgitaly/service/commit.py
- hgitaly/service/tests/test_commit.py 50 additions, 0 deletionshgitaly/service/tests/test_commit.py
- hgitaly/tests/test_linguist.py 61 additions, 0 deletionshgitaly/tests/test_linguist.py
- install-requirements.txt 1 addition, 0 deletionsinstall-requirements.txt
- setup.py 3 additions, 1 deletionsetup.py
- tests_with_gitaly/test_commit.py 45 additions, 0 deletionstests_with_gitaly/test_commit.py
Loading
Please register or sign in to comment