Skip to content
Myr

Ugly fix for filepath.IsAbs not playing nicely with windows

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jared Bydeley · committed by Steve Francia · parent 1f27c09 · Browse files · 2 files+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+2 added−2 removed

  • other:+2 added−2 removed

2 files+2 added−2 removed

modified:cobra/cmd/helpers_test.go+1 added-1 removed
29 unmodified lines
3031func TestProjectPath(t *testing.T) {32 checkGuess(t, "", filepath.Join("github.com", "spf13", "hugo"), filepath.Join(getSrcPath(), "github.com", "spf13", "hugo"))33 checkGuess(t, "", filepath.Join("spf13", "hugo"), filepath.Join(getSrcPath(), "github.com", "spf13", "hugo"))34 checkGuess(t, "", filepath.Join("/", "bar", "foo"), filepath.Join(getSrcPath(), "bar", "foo"))34 checkGuess(t, "", filepath.Join("/", "bar", "foo"), filepath.Join("/", "bar", "foo"))35 checkGuess(t, "/bar/foo", "baz", filepath.Join("/", "bar", "foo", "baz"))36 checkGuess(t, "/bar/foo/cmd", "", filepath.Join("/", "bar", "foo"))37 checkGuess(t, "/bar/foo/command", "", filepath.Join("/", "bar", "foo"))38 checkGuess(t, "/bar/foo/commands", "", filepath.Join("/", "bar", "foo"))
2 unmodified lines
modified:cobra/cmd/helpers.go+1 added-1 removed
141 unmodified lines
142143 srcPath := getSrcPath()144 // if provided, inspect for logical locations145 if strings.ContainsRune(inputPath, os.PathSeparator) {146 if filepath.IsAbs(inputPath) {146 if filepath.IsAbs(inputPath) || filepath.HasPrefix(inputPath, string(os.PathSeparator)) {147 // if Absolute, use it148 projectPath = filepath.Clean(inputPath)149 return150 }
197 unmodified lines