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

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


The following commit(s) were added to refs/heads/main by this push:
     new 95d8dc0  Fix some minor errors (#36)
95d8dc0 is described below

commit 95d8dc0b708e5048eb5ecb96eae4b001dc7ba6a9
Author: MoGuGuai-hzr <[email protected]>
AuthorDate: Thu Jul 8 10:18:50 2021 +0800

    Fix some minor errors (#36)
---
 pkg/config/config.go |  9 ++++-----
 pkg/header/check.go  | 16 ++++++++++++++--
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/pkg/config/config.go b/pkg/config/config.go
index 684f35a..afd8578 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -37,12 +37,11 @@ type Config struct {
 func (config *Config) Parse(file string) (err error) {
        var bytes []byte
 
-       if file != "" {
-               logger.Log.Infoln("Loading configuration from file:", file)
+       // attempt to read configuration from specified file
+       logger.Log.Infoln("Loading configuration from file:", file)
 
-               if bytes, err = os.ReadFile(file); err != nil && 
!os.IsNotExist(err) {
-                       return err
-               }
+       if bytes, err = os.ReadFile(file); err != nil && !os.IsNotExist(err) {
+               return err
        }
 
        if os.IsNotExist(err) {
diff --git a/pkg/header/check.go b/pkg/header/check.go
index 21bdb8d..e10b318 100644
--- a/pkg/header/check.go
+++ b/pkg/header/check.go
@@ -45,7 +45,7 @@ func Check(config *ConfigHeader, result *Result) error {
 var seen = make(map[string]bool)
 
 func checkPattern(pattern string, result *Result, config *ConfigHeader) error {
-       paths, err := doublestar.Glob(pattern)
+       paths, err := glob(pattern)
 
        if err != nil {
                return err
@@ -65,10 +65,22 @@ func checkPattern(pattern string, result *Result, config 
*ConfigHeader) error {
        return nil
 }
 
+func glob(pattern string) (matches []string, err error) {
+       if pattern == "." {
+               return doublestar.Glob("./")
+       }
+
+       return doublestar.Glob(pattern)
+}
+
 func checkPath(path string, result *Result, config *ConfigHeader) error {
        defer func() { seen[path] = true }()
 
-       if yes, err := config.ShouldIgnore(path); yes || seen[path] || err != 
nil {
+       if seen[path] {
+               return nil
+       }
+
+       if yes, err := config.ShouldIgnore(path); yes || err != nil {
                return err
        }
 

Reply via email to