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

Gitattributes #50

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Gitattributes #50

wants to merge 9 commits into from

Conversation

dpaz
Copy link
Contributor

@dpaz dpaz commented Jun 23, 2017

Added support for .gitattributes which works similar to github/linguist
#18

@dpaz dpaz requested review from mcarmonaa and smola June 23, 2017 08:43
@dpaz dpaz changed the title Gitatributes Gitattributes Jun 23, 2017
Copy link
Contributor

@smola smola left a 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.

README.md Outdated Show resolved Hide resolved
utils.go Outdated Show resolved Hide resolved
utils.go Outdated
return nil, err
}

if data != nil {
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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() {
Copy link
Contributor

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/callin/calling/

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?

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/oreder/order/

@mcarmonaa
Copy link
Contributor

@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]
Copy link
Contributor

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

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

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

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.

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 _?

Copy link
Contributor Author

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 {

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.
Copy link
Contributor

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?

Copy link
Contributor Author

@dpaz dpaz Jun 27, 2017

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.

Copy link
Contributor

@abeaumont abeaumont Jun 27, 2017

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

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) {
Copy link
Contributor

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())
Copy link
Contributor

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() {
Copy link
Contributor

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

Copy link
Contributor Author

@dpaz dpaz Jun 27, 2017

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

codecov bot commented Jun 27, 2017

Codecov Report

Merging #50 into master will decrease coverage by 0.97%.
The diff coverage is 75%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
common.go 90.73% <100%> (+0.37%) ⬆️
utils.go 71.3% <72.91%> (+8.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9de4d35...0a267e9. Read the comment docs.

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.

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.

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?

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{}

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

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.
Copy link
Contributor

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 {
Copy link
Contributor

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{
Copy link
Contributor

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 {

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

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 {

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

codecov-io commented Jul 4, 2017

Codecov Report

Merging #50 into master will decrease coverage by <.01%.
The diff coverage is 80.83%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
common.go 85.3% <0%> (-5.15%) ⬇️
gitattributes.go 89.81% <89.81%> (ø)
utils.go 100% <0%> (+26.31%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 200c153...11ef5ed. Read the comment docs.

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

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"
Copy link
Contributor

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

Copy link
Contributor Author

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}
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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 ""
Copy link
Contributor

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{}},
Copy link
Contributor

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 {
Copy link
Contributor

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)
}
Copy link
Contributor

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)
Copy link
Contributor

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

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space befor 'or'

@abeaumont
Copy link
Contributor

@dpaz Apart from the review changes, please rebase.

@dpaz dpaz force-pushed the gitatributes branch 2 times, most recently from 1018320 to 590817f Compare July 13, 2017 07:29
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
Copy link
Contributor

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

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

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

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/).
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

language == enry.OtherLanguage?

@abeaumont
Copy link
Contributor

@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.
Copy link
Contributor

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

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

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/

@mcarmonaa
Copy link
Contributor

As linguist's README says: Add a .gitattributes file to your project and use standard git-style path matchers for the files you want to override..., If we have a different way to specify a path and don't support the same style that linguist uses, we won't be compatible.

The same .gitattributes file should work with linguist and enry.

@dpaz
Copy link
Contributor Author

dpaz commented Jul 19, 2017

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.

@abeaumont
Copy link
Contributor

@dpaz how does linguist implement those regexps?

@abeaumont abeaumont self-assigned this Jul 19, 2017
@vmarkovtsev
Copy link
Collaborator

We need a hero to finish this!

hero

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.

7 participants