This is an automated email from the ASF dual-hosted git repository. kezhenxu94 pushed a commit to branch bug/license in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git
commit 3b136bff767f8817dc23420fb35f9e2b5b88130e Author: kezhenxu94 <[email protected]> AuthorDate: Fri Aug 13 18:46:26 2021 +0800 Fix wrong license identification --- pkg/license/identifier.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/license/identifier.go b/pkg/license/identifier.go index 7864713..e74da75 100644 --- a/pkg/license/identifier.go +++ b/pkg/license/identifier.go @@ -70,7 +70,9 @@ func Identify(pkgPath, content string) (string, error) { content = Normalize(content) for name, license := range normalizedTemplates { - if strings.Contains(content, license) { + // Should not use `Contains` as a root LICENSE file may include other licenses the project uses, + // `Contains` would identify the last one license as the project's license. + if strings.HasPrefix(content, license) { name = filepath.Base(name) return strings.TrimSuffix(name, filepath.Ext(name)), nil }
