Skip to content

Commit 3bc7dd3

Browse files
committed
cue/load: Unix-related fixes related to 5a3cce0
The new implementation did not work for the Kubernets test (using temp directories) on Linux. Also updated package golang.org/x/tools, as the old version did not work correctly on this same Linux system. Change-Id: I062cf179fbb1bfcd24bf3b5b0d09de9be9c53afb Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2743 Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent 240a995 commit 3bc7dd3

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

cue/load/import.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,14 @@ func updateDirs(c *Config, p *build.Instance, path, srcDir string, mode importMo
235235
}
236236

237237
func normPrefix(root, path string, isLocal bool) string {
238-
path, err := filepath.Rel(root, path)
239-
if err == nil && isLocal {
240-
path = "." + string(filepath.Separator) + path
238+
root = filepath.Clean(root)
239+
prefix := ""
240+
if isLocal {
241+
prefix = "." + string(filepath.Separator)
242+
}
243+
if !strings.HasSuffix(root, string(filepath.Separator)) &&
244+
strings.HasPrefix(path, root) {
245+
path = prefix + path[len(root)+1:]
241246
}
242247
return path
243248
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
golang.org/x/net v0.0.0-20190311183353-d8887717615a
1717
golang.org/x/sync v0.0.0-20190423024810-112230192c58
1818
golang.org/x/text v0.3.2
19-
golang.org/x/tools v0.0.0-20181210225255-6a3e9aa2ab77
19+
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384
2020
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373
2121
gopkg.in/yaml.v2 v2.2.2 // indirect
2222
)

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ golang.org/x/tools v0.0.0-20181210225255-6a3e9aa2ab77 h1:s+6psEFi3o1QryeA/qyvUoV
6363
golang.org/x/tools v0.0.0-20181210225255-6a3e9aa2ab77/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
6464
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg=
6565
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
66+
golang.org/x/tools v0.0.0-20190807164442-cae9aa543496 h1:wn6ujVyYPLpzl5zx7DCA9OFqjQiRyO7ll2KNAuwUl2A=
6667
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373 h1:PPwnA7z1Pjf7XYaBP9GL1VAMZmcIWyFz7QCMSIIa3Bg=
6768
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6869
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

0 commit comments

Comments
 (0)