Skip to content

Commit

Permalink
Fix path for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Jan 24, 2024
1 parent 082e500 commit 5c00111
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions datastore/datastore_unix_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !windows

package datastore

import (
Expand Down
2 changes: 1 addition & 1 deletion datastore/datastore_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
)

func TestParseUNIX(t *testing.T) {
func TestParseWindows(t *testing.T) {
var tests = []struct {
in string
wantType Type
Expand Down
8 changes: 4 additions & 4 deletions internal/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -36,15 +37,14 @@ func RootPath(base string) (string, error) {
func DetectPrefix(gitRoot, wd string, files, cfiles []string) string {
var rcfiles [][]string
for _, f := range cfiles {
s := strings.Split(f, "/")
s := strings.Split(filepath.FromSlash(f), string(filepath.Separator))
reverse(s)
rcfiles = append(rcfiles, s)
}

var rfiles [][]string
for _, f := range files {
s := strings.Split(f, "/")
// reverse slice
s := strings.Split(filepath.FromSlash(f), string(filepath.Separator))
reverse(s)
rfiles = append(rfiles, s)
}
Expand Down
4 changes: 2 additions & 2 deletions ratio/ratio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 5c00111

Please sign in to comment.