Skip to content

Commit 6f85879

Browse files
authored
Merge pull request #2222 from FabianKramm/main
fix: sync path parsing for windows
2 parents b7ffc1a + 49248e6 commit 6f85879

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

pkg/devspace/services/sync/controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ func ParseSyncPath(path string) (localPath string, remotePath string, err error)
301301

302302
splitted := strings.Split(path, ":")
303303
if len(splitted) > 2 {
304-
return "", "", fmt.Errorf("error in sync path %s: should have format local:remote", path)
304+
newSplitted := []string{}
305+
newSplitted = append(newSplitted, strings.Join(splitted[0:len(splitted)-1], ":"))
306+
newSplitted = append(newSplitted, splitted[len(splitted)-1])
307+
splitted = newSplitted
305308
}
306309

307310
if len(splitted) == 1 {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package sync
2+
3+
import (
4+
"gotest.tools/assert"
5+
"testing"
6+
)
7+
8+
type parseSyncPathTestCase struct {
9+
name string
10+
in string
11+
12+
expectedLocal string
13+
expectedRemote string
14+
}
15+
16+
func TestParseSyncPath(t *testing.T) {
17+
testCases := []parseSyncPathTestCase{
18+
{
19+
name: "Test Windows",
20+
in: "C:/codeproject:/home/dev/codeproject",
21+
expectedLocal: "C:/codeproject",
22+
expectedRemote: "/home/dev/codeproject",
23+
},
24+
}
25+
26+
for _, testCase := range testCases {
27+
local, remote, err := ParseSyncPath(testCase.in)
28+
assert.NilError(t, err)
29+
assert.Equal(t, local, testCase.expectedLocal, "Expect local path in "+testCase.name)
30+
assert.Equal(t, remote, testCase.expectedRemote, "Expect remote path in "+testCase.name)
31+
}
32+
}

0 commit comments

Comments
 (0)