From 47285ff92caa8f0f6f69b87b26bfd2537071f43b Mon Sep 17 00:00:00 2001 From: k1LoW Date: Wed, 24 Jan 2024 12:02:39 +0900 Subject: [PATCH] Fix path for Windows --- internal/path.go | 3 ++- ratio/ratio_test.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/path.go b/internal/path.go index 7551fdf1..23e9f620 100644 --- a/internal/path.go +++ b/internal/path.go @@ -25,7 +25,8 @@ func RootPath(base string) (string, error) { if fi, err := os.Stat(gitConfig); err == nil && !fi.IsDir() { return p, nil } - if p == "/" { + if filepath.Dir(p) == p { + // root directory break } p = filepath.Dir(p) diff --git a/ratio/ratio_test.go b/ratio/ratio_test.go index be275996..2719ff4e 100644 --- a/ratio/ratio_test.go +++ b/ratio/ratio_test.go @@ -103,7 +103,7 @@ func TestPathMatch(t *testing.T) { if err != nil { t.Fatal(err) } - want := "ratio/ratio_test.go" + want := filepath.FromSlash("ratio/ratio_test.go") ok := false for _, f := range got.CodeFiles { if f.Path == want { @@ -124,7 +124,7 @@ func TestPathMatch(t *testing.T) { if err != nil { t.Fatal(err) } - want := "ratio/ratio_test.go" + want := filepath.FromSlash("ratio/ratio_test.go") ok := false for _, f := range got.CodeFiles { if f.Path == want {