Skip to content

Commit 2c21bdf

Browse files
committed
adjust trailing path conflict detection in Windows
1 parent 8bd4a93 commit 2c21bdf

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

validate/validate.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ func checkTrailingPeriodConflictInWindows(
271271
)
272272

273273
for _, v := range pathComponents {
274+
if v == "." || v == ".." {
275+
continue
276+
}
277+
274278
if v != strings.TrimRight(v, ".") {
275279
conflictDetected = true
276280

@@ -284,6 +288,10 @@ func checkTrailingPeriodConflictInWindows(
284288

285289
if ctx.autoFix && conflictDetected {
286290
for j, v := range pathComponents {
291+
if v == "." || v == ".." {
292+
continue
293+
}
294+
287295
s := strings.TrimRight(v, ".")
288296
pathComponents[j] = s
289297
}

validate/validate_test/validate_windows_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ func TestValidateWindows(t *testing.T) {
2727
},
2828
ConflictDetected: true,
2929
},
30+
{
31+
Name: ".. and . should not trigger a conflict",
32+
Changes: file.Changes{
33+
{
34+
Source: "index.js",
35+
Target: "../index.js",
36+
BaseDir: "dev/nested",
37+
Status: status.OK,
38+
},
39+
{
40+
Source: "main.js",
41+
Target: "./main.js",
42+
BaseDir: "dev",
43+
Status: status.Unchanged,
44+
},
45+
},
46+
Want: []string{"dev/index.js", "dev/main.js"},
47+
},
3048
{
3149
Name: "detect trailing period conflict in directories",
3250
Changes: file.Changes{

0 commit comments

Comments
 (0)