You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by ke...@apache.org on 2021/05/07 07:56:14 UTC

[skywalking-eyes] branch tolerate/whitespaces created (now 87a013e)

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a change to branch tolerate/whitespaces
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git.


      at 87a013e  enhance: tolerate leading whitespaces in license header

This branch includes the following new commits:

     new 87a013e  enhance: tolerate leading whitespaces in license header

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[skywalking-eyes] 01/01: enhance: tolerate leading whitespaces in license header

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch tolerate/whitespaces
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 87a013eeef33b63d2c02c7f609effe1152dfdd37
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Fri May 7 15:55:56 2021 +0800

    enhance: tolerate leading whitespaces in license header
---
 pkg/license/norm.go | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/pkg/license/norm.go b/pkg/license/norm.go
index f18daa1..1b1bd74 100644
--- a/pkg/license/norm.go
+++ b/pkg/license/norm.go
@@ -19,8 +19,12 @@
 package license
 
 import (
+	"reflect"
 	"regexp"
+	"runtime"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
 )
 
 type Normalizer func(string) string
@@ -127,7 +131,7 @@ var (
 	}{
 		// BSD-3-Clause
 		{
-			regexp.MustCompile(`(?im)(^(Copyright \(c\)) (\d{4}) (.+?) (All rights reserved\.)?$\n?)+`),
+			regexp.MustCompile(`(?im)(^(\s*Copyright \(c\)) (\d{4}) (.+?) (All rights reserved\.)?$\n?)+`),
 			"$2 [year] [owner]. $5",
 		},
 		{
@@ -136,11 +140,11 @@ var (
 		},
 		// MIT
 		{ // remove optional header
-			regexp.MustCompile(`(?im)^The MIT License \(MIT\)$`),
+			regexp.MustCompile(`(?im)^\s*The MIT License \(MIT\)$`),
 			"",
 		},
 		{
-			regexp.MustCompile(`(?im)^(Copyright \(c\)) (\d{4}) (.+?)$`),
+			regexp.MustCompile(`(?im)^(\s*Copyright \(c\)) (\d{4}) (.+?)$`),
 			"$1 [year] [owner]",
 		},
 		{
@@ -162,7 +166,9 @@ func NormalizePattern(pattern string) string {
 func NormalizeHeader(header string) string {
 	ns := append([]Normalizer{CommentIndicatorNormalizer}, normalizers...)
 	for _, normalize := range ns {
+		logger.Log.Debugf("After normalized by %+v:", runtime.FuncForPC(reflect.ValueOf(normalize).Pointer()).Name())
 		header = normalize(header)
+		logger.Log.Debugln(header)
 	}
 	return header
 }