Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4891cbf

Browse files
committed
allow more abs paths on windows, transform unix
1 parentb1f10a7 commit4891cbf

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

‎cli/open.go‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,15 @@ func isWindowsAbsPath(p string) bool {
243243
returnfilepath.IsAbs(p)
244244
}
245245

246+
// Remove the drive letter, if present.
247+
iflen(p)>=2&&p[1]==':' {
248+
p=p[2:]
249+
}
250+
246251
switch {
247-
caselen(p)<2:
252+
caselen(p)==0:
248253
returnfalse
249-
casep[1]==':':
250-
// Path starts with a drive letter.
251-
returnlen(p)==2|| (len(p)>=3&&p[2]=='\\')
252-
casep[0]=='\\'&&p[1]=='\\':
253-
// Path starts with \\.
254+
casep[0]=='/'||p[0]=='\\':
254255
returntrue
255256
default:
256257
returnfalse
@@ -309,7 +310,7 @@ func resolveAgentAbsPath(workingDirectory, relOrAbsPath, agentOS string, local b
309310
caseworkingDirectory!=""&&!isWindowsAbsPath(relOrAbsPath):
310311
returnwindowsJoinPath(workingDirectory,relOrAbsPath),nil
311312
caseisWindowsAbsPath(relOrAbsPath):
312-
returnrelOrAbsPath,nil
313+
returnwindowsJoinPath(relOrAbsPath),nil
313314
default:
314315
return"",xerrors.Errorf("path %q not supported, use an absolute path instead",relOrAbsPath)
315316
}

‎cli/open_internal_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ func Test_resolveAgentAbsPath(t *testing.T) {
3333
{"ok with working directory and rel path on windows",args{workingDirectory:"C:\\some\\path",relOrAbsPath:"other\\path",agentOS:"windows"},"C:\\some\\path\\other\\path",false},
3434
{"ok with working directory and abs path on windows",args{workingDirectory:"C:\\some\\path",relOrAbsPath:"C:\\other\\path",agentOS:"windows"},"C:\\other\\path",false},
3535
{"ok with no working directory and abs path on windows",args{relOrAbsPath:"C:\\other\\path",agentOS:"windows"},"C:\\other\\path",false},
36+
{"ok abs unix path on windows",args{workingDirectory:"C:\\some\\path",relOrAbsPath:"/other/path",agentOS:"windows"},"\\other\\path",false},
37+
{"ok rel unix path on windows",args{workingDirectory:"C:\\some\\path",relOrAbsPath:"other/path",agentOS:"windows"},"C:\\some\\path\\other\\path",false},
3638

3739
{"fail with no working directory and rel path on windows",args{relOrAbsPath:"other\\path",agentOS:"windows"},"",true},
3840
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp