blackducksoftware / ohcount

The Ohloh source code line counter
https://github.com/blackducksoftware/ohcount
GNU General Public License v2.0
261 stars 69 forks source link

Please take into account .gitattributes linguist-language entries, including for unrecognized languages #89

Open ell1e opened 11 months ago

ell1e commented 11 months ago

As a new feature, I suggest you support .gitattributes linguist-language entries, including for unrecognized languages. This is already supported by Gitea and means if a repository contains a completely new, and/or very domain-specific niche language, an entry in .gitattributes provided by the repository maintainers will easily make everything "just work". If the tooling plays along of course, which ohcount currently doesn't.

Current output:

$ git init .
Initialized empty Git repository in /home/user/test/.git/
$ echo -e "A\n\nB\nC" > ./test.mylang
$ echo "*.mylang linguist-language=MyLang" > .gitattributes
$ git add test.mylang .gitattributes 
$ git commit -m "Language count test"
[main (root-commit) e716e77] Language count test
 2 files changed, 4 insertions(+)
 create mode 100644 .gitattributes
 create mode 100644 test.mylang
$ ohcount .
Examining 2 file(s)

                          Ohloh Line Count Summary                          

Language          Files       Code    Comment  Comment %      Blank      Total
----------------  -----  ---------  ---------  ---------  ---------  ---------
----------------  -----  ---------  ---------  ---------  ---------  ---------
Total                 0          0          0       0.0%          0          0

Expected output:

$ git init .
Initialized empty Git repository in /home/user/test/.git/
$ echo -e "A\n\nB\nC" > ./test.mylang
$ echo "*.mylang linguist-language=MyLang" > .gitattributes
$ git add test.mylang .gitattributes 
$ git commit -m "Language count test"
[main (root-commit) e716e77] Language count test
 2 files changed, 4 insertions(+)
 create mode 100644 .gitattributes
 create mode 100644 test.mylang
$ ohcount .
Examining 2 file(s)

                          Ohloh Line Count Summary                          

Language          Files       Code    Comment  Comment %      Blank      Total
----------------  -----  ---------  ---------  ---------  ---------  ---------
MyLang                1          3          0       0.0%          1          4
----------------  -----  ---------  ---------  ---------  ---------  ---------
Total                 1          3          0       0.0%          1          4