Skip to content

Commit 0079eff

Browse files
committed
fix around samePath in testing
1 parent e02ce88 commit 0079eff

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ on:
33
push:
44
branches:
55
- "**"
6-
pull_request: {}
76
jobs:
87
test:
98
runs-on: ${{ matrix.os }}

cmd_root_test.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ import (
1212
)
1313

1414
func samePath(lhs, rhs string) bool {
15-
if runtime.GOOS != "windows" {
16-
return lhs == rhs
17-
}
18-
19-
lhs, _ = filepath.Abs(filepath.Clean(lhs))
20-
rhs, _ = filepath.Abs(filepath.Clean(rhs))
21-
return strings.EqualFold(lhs, rhs)
15+
return lhs == rhs
2216
}
2317

2418
func samePaths(lhs, rhs string) bool {
@@ -27,12 +21,7 @@ func samePaths(lhs, rhs string) bool {
2721
}
2822
lhss := strings.Split(lhs, "\n")
2923
rhss := strings.Split(rhs, "\n")
30-
for i := range lhss {
31-
if !samePath(lhss[i], rhss[i]) {
32-
return false
33-
}
34-
}
35-
return true
24+
return samePathSlice(lhss, rhss)
3625
}
3726

3827
func TestDoRoot(t *testing.T) {

local_repository_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,31 @@ import (
66
"reflect"
77
"runtime"
88
"sort"
9+
"strings"
910
"sync"
1011
"testing"
1112

1213
"github.com/Songmu/gitconfig"
1314
)
1415

1516
func samePathSlice(lhss, rhss []string) bool {
16-
sort.Strings(lhss)
17-
sort.Strings(rhss)
18-
for i := range lhss {
19-
if !samePath(lhss[i], rhss[i]) {
17+
if len(lhss) != len(rhss) {
18+
return false
19+
}
20+
lhssAbs := make([]string, len(lhss))
21+
rhssAbs := make([]string, len(rhss))
22+
23+
for i, p := range lhss {
24+
lhsAbs, _ := filepath.Abs(filepath.Clean(p))
25+
lhssAbs[i] = strings.ToLower(lhsAbs)
26+
27+
rhsAbs, _ := filepath.Abs(filepath.Clean(rhss[i]))
28+
rhssAbs[i] = strings.ToLower(rhsAbs)
29+
}
30+
sort.Strings(lhssAbs)
31+
sort.Strings(rhssAbs)
32+
for i := range lhssAbs {
33+
if !samePath(lhssAbs[i], rhssAbs[i]) {
2034
return false
2135
}
2236
}

0 commit comments

Comments
 (0)