-
Notifications
You must be signed in to change notification settings - Fork 51
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
Gitattributes #50
base: master
Are you sure you want to change the base?
Gitattributes #50
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work on bare repositories. Let's think how we should modify the API so that it does.
utils.go
Outdated
return nil, err | ||
} | ||
|
||
if data != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you actually want to avoid the code inside the if statement, you should check for len(data) > 0
, if ioutil.ReadFile doesn't fail it could return an empty slice and an empty slice in not nil.
utils.go
Outdated
|
||
if data != nil { | ||
tokens := strings.Fields(string(data)) | ||
for i := 0; i < len(tokens); i = i + 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should use a scanner or split before by lines, it's not so clear what are you doing here at a glance
utils.go
Outdated
|
||
func parseAttributes(attributes map[string]string) { | ||
for key, val := range attributes { | ||
switch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the same path has several attributes?
utils.go
Outdated
} | ||
} | ||
|
||
func LoadGitAttributes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this function before loadGitattributes() and add a comment if it is a public function
common.go
Outdated
@@ -87,6 +88,12 @@ func GetLanguageByClassifier(content []byte, candidates []string) (language stri | |||
return getLanguageByStrategy(GetLanguagesByClassifier, "", content, candidates) | |||
} | |||
|
|||
// GetLanguageByGitAttributes returns the language assigned for a given regular expresion in .gitattributes. | |||
// This strategy needs to be initialized callin LoadGitAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/callin/calling/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this on demand instead of having to call LoadGitAttributes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the argument to this function? a filename or a regular expression (function signature says the former, comment explains the later)
README.md
Outdated
@@ -33,6 +33,7 @@ fmt.Println(lang) | |||
lang := enry.GetLanguage("foo.cpp", "<cpp-code>") | |||
``` | |||
|
|||
|
|||
Developmemt | |||
----------- | |||
*enry* re-uses parts of original [linguist](https://github.com/github/linguist) especially data in `languages.yml` to generate internal data structures. In oreder to update to latest upstream run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/oreder/order/
@dpaz You should add tests for new functionality |
utils.go
Outdated
if len(tokens) == 2 { | ||
regExp, err := regexp.Compile(regExpString) | ||
if err == nil { | ||
languageGitAttributes[regExp] = tokens[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should pass tokens[1] to GetLanguageByAlias() before store it in the map, this ensures the language will be stored like a "standard name" if it is a known language for enry
common.go
Outdated
@@ -87,6 +88,12 @@ func GetLanguageByClassifier(content []byte, candidates []string) (language stri | |||
return getLanguageByStrategy(GetLanguagesByClassifier, "", content, candidates) | |||
} | |||
|
|||
// GetLanguageByGitAttributes returns the language assigned for a given regular expresion in .gitattributes. | |||
// This strategy needs to be initialized callin LoadGitAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this on demand instead of having to call LoadGitAttributes
?
common.go
Outdated
@@ -87,6 +88,12 @@ func GetLanguageByClassifier(content []byte, candidates []string) (language stri | |||
return getLanguageByStrategy(GetLanguagesByClassifier, "", content, candidates) | |||
} | |||
|
|||
// GetLanguageByGitAttributes returns the language assigned for a given regular expresion in .gitattributes. | |||
// This strategy needs to be initialized callin LoadGitAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the argument to this function? a filename or a regular expression (function signature says the former, comment explains the later)
common.go
Outdated
@@ -434,3 +441,20 @@ func GetLanguageByAlias(alias string) (lang string, ok bool) { | |||
|
|||
return | |||
} | |||
|
|||
// GetLanguagesByGitAttributes returns the language assigned in .gitattributes if the regular expresion | |||
// matchs with the filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading comment: It returns a slice of languages, not a language.
The difference between this method and GetLanguageByGitAttributes
should be made much clear and probably their names should be much different also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this function ignoring most of its arguments?
If it is to implemement and interface, it would be nice to know, and why are they being ignored in this particular implementation. Also give ignored arguments a good name, like _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some info to say that it is implementing an interface, the rest of the things that you are telling me are like this to be coherent with the other strategies that are written similarly.
common.go
Outdated
return languageByGitAttribute(filename) | ||
} | ||
|
||
func languageByGitAttribute(filename string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this function exists? can its code be part of its caller body?
Shouldn't it be called languages...
instead of language...
?
README.md
Outdated
-------------- | ||
|
||
Like in linguist you can override the strategies via `.gitattributes` file. | ||
Add a `.gitattributes` file to the directory and use the enry matchers `enry-documentation`,`enry-language` or `enry-vendored` to do the override. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how linguist
works, but why are we using specific enry matchers instead of reusing the linguist ones? Or are we adding these enry matchers on top of the linguist ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its only a name, they called linguist-documentation or linguist-vendored because is part of linguist, I thought that because we are on enry we should call it enry-vendored and enry-documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if you name them differently you're forcing the user to have to support both linguist
and enry
separately. If you just use the same name, enry will already support all those attributes already customized by users for linguist
, since enry
would be fully compatible with linguist
.
utils.go
Outdated
@@ -66,3 +83,99 @@ func IsBinary(data []byte) bool { | |||
|
|||
return true | |||
} | |||
|
|||
// LoadGitattributes reads and parse the file .gitattributes wich overrides the standards strategies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/parse/parses/
s/wich/which/
s/standards/standard/
utils.go
Outdated
} | ||
} | ||
|
||
func loadGitattributes(name string) (map[string]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore me if this is some kind of Go convention, but having 2 functions whose only difference in the name is the case of the first letter seems pretty confunsing to me
utils.go
Outdated
data, err := ioutil.ReadFile(name) | ||
if err != nil { | ||
if err != os.ErrNotExist { | ||
log.Println(".gitattributes: " + err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Println(name + ": " + err.Error())
?
utils_test.go
Outdated
@@ -81,6 +82,42 @@ func (s *SimpleLinguistTestSuite) TestIsBinary() { | |||
} | |||
} | |||
|
|||
func (s *SimpleLinguistTestSuite) TestLoadLine() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should be EnryTestSuite
as this point :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes the PR was not merged till yesterday I will change this
Codecov Report
@@ Coverage Diff @@
## master #50 +/- ##
==========================================
- Coverage 84.78% 83.81% -0.98%
==========================================
Files 16 16
Lines 940 1044 +104
==========================================
+ Hits 797 875 +78
- Misses 84 103 +19
- Partials 59 66 +7
Continue to review full report at Codecov.
|
common.go
Outdated
@@ -434,3 +441,16 @@ func GetLanguageByAlias(alias string) (lang string, ok bool) { | |||
|
|||
return | |||
} | |||
|
|||
// GetLanguagesByGitattributes returns a length 1 slice with the language assigned in .gitattributes if the regular expresion | |||
// matchs with the filename. It is comply with the signature to be a Strategy type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve the English and the explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that it returns an empty slice if the filename does not match any of the rules in .gitattributes. Should this return nil instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called GetLanguagesByGitAttributes
with an uppercase A
. The same for all git attributes functions and variables, except for the name of the file (.gitattributes
) itself, of course.
common.go
Outdated
// GetLanguagesByGitattributes returns a length 1 slice with the language assigned in .gitattributes if the regular expresion | ||
// matchs with the filename. It is comply with the signature to be a Strategy type. | ||
func GetLanguagesByGitattributes(filename string, content []byte, candidates []string) []string { | ||
languages := []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is better, to clarify the interface to remove this allocation from here and move it to the return statement, as otherwise we are allocating a slice to return it empty in case the filename does not match any languageGitattributes.
common.go
Outdated
@@ -453,9 +453,11 @@ func GetLanguageByAlias(alias string) (lang string, ok bool) { | |||
// GetLanguagesByGitAttributes returns either a string slice with the lenguage if the filename match with a regExp in .gitattributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/lenguage/language/
s/match/matches/
common.go
Outdated
@@ -453,9 +453,11 @@ func GetLanguageByAlias(alias string) (lang string, ok bool) { | |||
// GetLanguagesByGitAttributes returns either a string slice with the lenguage if the filename match with a regExp in .gitattributes | |||
//or return nil in case of none regexp matchs the filename . It complies with the signature to be a Strategy type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- space before or
- s/return/returns/
- no space after filename
- s/in case of none/in case no/
- s/matchs/matches/
common.go
Outdated
for regExp, language := range languageGitAttributes { | ||
if regExp.MatchString(filename) { | ||
return []string{language} | ||
if loadedGitAttributes != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think having a global variable floating around different files is a good idea.
utils.go
Outdated
err = errors.New(fmt.Sprintf("gitattributes: The matcher %s doesn't exists\n", attribute)) | ||
log.Printf(err.Error()) | ||
func newGitAttributes() *gitAttributes { | ||
gA := gitAttributes{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gA
is not too meaningful, and it doesn't make sense to upcase the 'A'.
I'd prefer something like 'attrs' or 'attributes', but since really short names are already used elsewhere, at least use proper casing: ga
common.go
Outdated
// GetLanguagesByGitAttributes returns either a string slice with the lenguage if the filename match with a regExp in .gitattributes | ||
//or return nil in case of none regexp matchs the filename . It complies with the signature to be a Strategy type. | ||
func GetLanguagesByGitAttributes(filename string, content []byte, candidates []string) []string { | ||
if loadedGitAttributes != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idiomatic way to do this in Go is to return nil if the loadedGitAttributes is == nil. That way, the happy path of the function (the for loop) has the smallest level of indentation. For a better explanation of this concept, see Golang UK Conference 2016 - Mat Ryer - Idiomatic Go Tricks (https://www.youtube.com/watch?v=yeetIgNeIkc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I approved the PR by mistake, let's try again:
The idiomatic way to do this in Go is to return nil if the loadedGitAttributes is == nil. That way, the happy path of the function (the for loop) has the smallest level of indentation. For a better explanation of this concept, see Golang UK Conference 2016 - Mat Ryer - Idiomatic Go Tricks (https://www.youtube.com/watch?v=yeetIgNeIkc).
common.go
Outdated
// GetLanguagesByGitAttributes returns either a string slice with the lenguage if the filename match with a regExp in .gitattributes | ||
//or return nil in case of none regexp matchs the filename . It complies with the signature to be a Strategy type. | ||
func GetLanguagesByGitAttributes(filename string, content []byte, candidates []string) []string { | ||
if loadedGitAttributes != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I approved the PR by mistake, let's try again:
The idiomatic way to do this in Go is to return nil if the loadedGitAttributes is == nil. That way, the happy path of the function (the for loop) has the smallest level of indentation. For a better explanation of this concept, see Golang UK Conference 2016 - Mat Ryer - Idiomatic Go Tricks (https://www.youtube.com/watch?v=yeetIgNeIkc).
Codecov Report
@@ Coverage Diff @@
## master #50 +/- ##
==========================================
- Coverage 85.03% 85.02% -0.01%
==========================================
Files 16 17 +1
Lines 942 1062 +120
==========================================
+ Hits 801 903 +102
- Misses 83 99 +16
- Partials 58 60 +2
Continue to review full report at Codecov.
|
common.go
Outdated
if regExp.MatchString(filename) { | ||
return append(languages, language) | ||
} | ||
// GetLanguagesByGitAttributes returns either a string slice with the language if the filename matches with a regExp in .gitattributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this function with the rest of the strategies
gitattributes.go
Outdated
language | ||
) | ||
|
||
const _attrType_name = "vendordocumentationgeneratedlanguage" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are indicating the underscores? I though this is not so idiomatic in Go.
On the other hand, why don't you use the previous constants as a string turning attrType a string type? Seems like it's adding unnecessary complexity, with _attr_index and the method for attrType String
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is autogenerated code by the command tool stringer its the most simple way to do a toString when you got an enum stringer
gitattributes.go
Outdated
|
||
const _attrType_name = "vendordocumentationgeneratedlanguage" | ||
|
||
var _attrType_index = [...]uint8{0, 6, 19, 28, 36} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the underscores?
path string | ||
} | ||
|
||
func (e *overrideError) Error() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we take attributes overriding as an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if an error is found nothing happens when the LoadAttributes function ends, it returns a slice of warnings that you can ignore, I'm only using this for traceability and testing purposes
gitattributes.go
Outdated
|
||
// IsVendor returns whether or not path is a documentation path. | ||
func (gitAttrs *GitAttributes) IsDocumentation(path string) bool { | ||
if val, ok := gitAttrs.boolAttributes[documentation].attributes[path]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can keep only those attributes which are "true". If the attribute is not in the map it's false, so you can check if the attribute is in the map.
if _, ok := gitAttrs.boolAttributes[documentation].attributes[path]; ok { return ok }
In this way, if we eventually allow attributes overriding, when load an attribute set to false, look for it in the map to delete it
gitattributes.go
Outdated
} | ||
} | ||
|
||
return "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return OtherLanguage
gitattributes.go
Outdated
func NewGitAttributes() *GitAttributes { | ||
gitAttrs := GitAttributes{ | ||
boolAttributes: map[attrType]boolAttribute{ | ||
vendor: boolAttribute{kind: vendor, matchers: []string{"linguist-vendored", "linguist-vendored=false"}, attributes: map[string]bool{}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If attrType were a string, you could remove the "kind" field from boolAttribute and regExpAttribute. In fact, the kind of these structs should be their type. If a type needs to explicitly keep a "kind" maybe it should be several types with perhaps a common parent type
gitattributes.go
Outdated
return append(gitAttrs.parseAttributes(path, rawAttributes), errArr...) | ||
} | ||
|
||
func (gitAttrs *GitAttributes) String() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this function is needed?
gitattributes.go
Outdated
|
||
for key, val := range gitAttrs.regExpAttributes { | ||
out += fmt.Sprintf("Type: %s Attributes: %v\n", key, val.attributes) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add an empty line after this one
for _, line := range lines { | ||
err := loadLine(line, rawAttributes) | ||
if err != nil { | ||
errArr = append(errArr, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we found a malformed .gitattributes file, we can return a "malformed error" and return nil and one error.
I don't know if we should allow to load a malformed .gitattributes file and return a slice of errors. We can be sure that the rest of attributes are ok if there are errors in the file?
common.go
Outdated
@@ -410,6 +410,24 @@ func GetLanguagesBySpecificClassifier(content []byte, candidates []string, class | |||
return classifier.Classify(content, mapCandidates) | |||
} | |||
|
|||
// GetLanguagesByGitAttributes returns either a string slice with the language if the filename matches with a regExp in .gitattributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These rows are too long
common.go
Outdated
@@ -410,6 +410,24 @@ func GetLanguagesBySpecificClassifier(content []byte, candidates []string, class | |||
return classifier.Classify(content, mapCandidates) | |||
} | |||
|
|||
// GetLanguagesByGitAttributes returns either a string slice with the language if the filename matches with a regExp in .gitattributes | |||
//or returns a empty slice in case no regexp matches the filename. It complies with the signature to be a Strategy type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space befor 'or'
@dpaz Apart from the review changes, please rebase. |
1018320
to
590817f
Compare
README.md
Outdated
@@ -139,6 +139,36 @@ Using [linguist/samples](https://github.com/github/linguist/tree/master/samples) | |||
* all files for SQL language fall to the classifier because we don't parse this [disambiguator expresion](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb#L433) for `*.sql` files right. This expression doesn't comply with the pattern for the rest of [heuristics.rb](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb) file. | |||
|
|||
|
|||
.gitAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all lowercase
README.md
Outdated
Use the `linguist-vendored` attribute to vendor or un-vendor paths. | ||
|
||
``` | ||
$cat .gitattributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space before cat
README.md
Outdated
If you want some files to be classified according to certain language use `linguist-language=[language]`. | ||
|
||
``` | ||
$cat .gitattributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space before cat
README.md
Outdated
.*\.go linguist-language=MyFavouriteLanguage | ||
``` | ||
Note, that the regular expression that match the file name should be one compatible with go, see: [Golang regexp](https://golang.org/pkg/regexp/). | ||
>>>>>>> 18e17c9... Added support for language attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be here
README.md
Outdated
$cat .gitattributes | ||
.*\.go linguist-language=MyFavouriteLanguage | ||
``` | ||
Note, that the regular expression that match the file name should be one compatible with go, see: [Golang regexp](https://golang.org/pkg/regexp/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- s/Note, that/Note that/
- s/match/matches/
- s/be one/be/
cli/enry/main.go
Outdated
} | ||
|
||
language := gitAttributes.GetLanguage(filepath.Base(path)) | ||
if len(language) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
language == enry.OtherLanguage
?
@mcarmonaa can you validate if everything is ok from your side? |
README.md
Outdated
-------------- | ||
|
||
Like in linguist you can override the strategies via `.gitattributes` file. | ||
Add a `.gitattributes` file to the directory and use the same matchers that you would uses in linguist `linguist-documentation`,`linguist-language` or `linguist-vendored` to do the override. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/uses/use/
|
||
``` | ||
$ cat .gitattributes | ||
.*\.go linguist-language=MyFavouriteLanguage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the regex must be compatible with Golang regexp, does it mean that a .gitattribute file used in linguist has a different syntax? Does it make .gitattributes files for enry incompatibles with linguist ones?
common.go
Outdated
@@ -407,6 +414,25 @@ func GetLanguagesBySpecificClassifier(content []byte, candidates []string, class | |||
return classifier.Classify(content, mapCandidates) | |||
} | |||
|
|||
// GetLanguagesByGitAttributes returns either a string slice with the language | |||
// if the filename matches with a regExp in .gitattributes or returns a empty slice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/a empty/an empty/
As linguist's README says: The same |
Like @mcarmonaa is saying, I don't really know If go regexps are a superset of git path matchers, If they are this will be fully compatible, if not we need to add some intermediate regexp motor, a converter or something. |
@dpaz how does |
Added support for .gitattributes which works similar to github/linguist
#18