linguist icon indicating copy to clipboard operation
linguist copied to clipboard

support overrides from .gitattributes

Open bacongobbler opened this issue 6 years ago • 6 comments

linguist supports a number of different custom overrides strategies for language definitions and vendored paths. This ports that effort over to this Go port of linguist.

See https://github.com/github/linguist#overrides

bacongobbler avatar Sep 19 '17 21:09 bacongobbler

Neat! I didn't know github/linguist had this feature. It would be nice to achieve feature parity with it where possible. Thank you for this. :D

Unfortunately, I can't seem to test out this new behavior... I merged the changes and made a .gitattributes file in a test repo but I can't seem to get it to do anything different... :S

Would you mind providing a sample testcase (like a sample .gitattributes demoing each keyword linguist-vendored, -documentation, -language along with a sample directory listing) that I can use to verify that this works and what the intended behavior should be? :)

Cheers, -tso

dayvonjersen avatar Sep 20 '17 10:09 dayvonjersen

I stared at the README for a while longer and wrote my own implementation: https://github.com/generaltso/linguist/compare/feature/gitattributes

I won't merge it, even though it works after a simple test:

test_repo
|-- .gitattributes
|-- docs
|   `-- test_dox.php
`-- test.go

test_dox.php:

<?php
$lololol='12';

test.go:

package main

func main() {
	println("Hello world!")
}

testing language override .gitattributes:

test.go linguist-language=PHP

result:

PHP: 100.0000%

1 language detected in 2 files
2 ignored paths

testing ignore specific paths

.gitattributes:

docs\test_dox.php linguist-documentation

result:

Go: 100.0000%

1 language detected in 1 file
3 ignored paths

Need to normalize path separators on Windows but again, not merging this.

I just was bored and wanted to wrap my head around the problem.

dayvonjersen avatar Sep 20 '17 12:09 dayvonjersen

Yeah I can write unit tests for this. I have unit tests covering this functionality at https://github.com/Azure/draft. I can port those tests over here.

bacongobbler avatar Sep 20 '17 14:09 bacongobbler

@bacongobbler what's the status with this? :thinking:

dayvonjersen avatar Oct 19 '17 00:10 dayvonjersen

Sorry! Been busy with other work over the last month. I’ve been maintaining a fork over at Azure/draft#344. There are a few issues with this effort so I’ve been meaning to write some more thorough tests. Once that’s done I’ll port the changes back here. :)

Thanks for the ping!

bacongobbler avatar Oct 19 '17 04:10 bacongobbler

Okay, I've written a pretty good suite of tests and it's all working. I'll port changes back over here over the holidays and should have this PR ready by the end of the year. Please ping me in 2018 if I don't hold up my end of the bargain :)

bacongobbler avatar Nov 28 '17 20:11 bacongobbler