Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support overrides from .gitattributes #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bacongobbler
Copy link

@bacongobbler bacongobbler commented Sep 19, 2017

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

linguist supports a number of different custom overrides strategies for language definitions and vendored paths.
@dayvonjersen
Copy link
Owner

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 added a commit that referenced this pull request Sep 20, 2017
Less-than-robust, straightforward implementation of https://github.com/github/linguist#overrides

See also: #5
@dayvonjersen
Copy link
Owner

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.

@bacongobbler
Copy link
Author

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.

@dayvonjersen
Copy link
Owner

@bacongobbler what's the status with this? 🤔

@bacongobbler
Copy link
Author

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
Copy link
Author

bacongobbler commented Nov 28, 2017

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants