Closed client9 closed 9 years ago
mind adding a test case?
yup.. I 'll sort it out with a test.
ok take a look.. I changed the existing test to use mixed case for license file (implicit check), and then added tests for the case insensitive matching explicitly.
Added a few comments but looking good! Thanks for tackling this.
updated with exception of "Now that I'm thinking about this more, we should probably report if there is more than a single license file found that we recognize, to avoid reporting the wrong license type." since that might require an API change, and is a separate bug.
@client9 does erroring on multiple matched licenses force an API change? Both NewFromDir()
and GuessFile()
return an error
, which should be sufficient to report a static error to the tune of "Multiple possible licenses found, cannot guess type". I also understand that this problem exists in the current code, and if you'd rather someone else tackle that in a different PR, that's ok, but we are touching all of the relevant code here so I thought we might as well get it all right. Just let me know!
Ahh, ok. I was think you meant changing
type License struct {
Type string // The type of license in use
Text string // License text data
File string // The path to the source file, if any
}
to be File []string
or something.
Returning an error if multiple matches is simple, and makes sense.
will do later today.
thx
n
update to err if there are multiple licenses found in a directory.
Looks good! I think at this point we are just missing a test for multiple license errors.
Ah yes. ok good will do shortly
sample license that would have been missed by old implementation:
LGTM. Thanks!
for your review... the existing tests actually seem to do exercise some of this already. Let me know if you want more tests.