mirror of
https://github.com/moby/buildkit.git
synced 2026-08-12 22:16:54 +00:00
Merge pull request #858 from tonistiigi/dedupe-fix
llbsolver: fix selectors dedupe
This commit is contained in:
@@ -165,7 +165,7 @@ func dedupePaths(inp []string) []string {
|
||||
for p1 := range old {
|
||||
var skip bool
|
||||
for p2 := range old {
|
||||
if p1 != p2 && strings.HasPrefix(p1, p2) {
|
||||
if p1 != p2 && strings.HasPrefix(p1, p2+"/") {
|
||||
skip = true
|
||||
break
|
||||
}
|
||||
|
||||
27
solver/llbsolver/ops/exec_test.go
Normal file
27
solver/llbsolver/ops/exec_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestDedupPaths(t *testing.T) {
|
||||
res := dedupePaths([]string{"Gemfile", "Gemfile/foo"})
|
||||
require.Equal(t, []string{"Gemfile"}, res)
|
||||
|
||||
res = dedupePaths([]string{"Gemfile/bar", "Gemfile/foo"})
|
||||
require.Equal(t, []string{"Gemfile/bar", "Gemfile/foo"}, res)
|
||||
|
||||
res = dedupePaths([]string{"Gemfile", "Gemfile.lock"})
|
||||
require.Equal(t, []string{"Gemfile", "Gemfile.lock"}, res)
|
||||
|
||||
res = dedupePaths([]string{"Gemfile.lock", "Gemfile"})
|
||||
require.Equal(t, []string{"Gemfile", "Gemfile.lock"}, res)
|
||||
|
||||
res = dedupePaths([]string{"foo", "Gemfile", "Gemfile/foo"})
|
||||
require.Equal(t, []string{"Gemfile", "foo"}, res)
|
||||
|
||||
res = dedupePaths([]string{"foo/bar/baz", "foo/bara", "foo/bar/bax", "foo/bar"})
|
||||
require.Equal(t, []string{"foo/bar", "foo/bara"}, res)
|
||||
}
|
||||
Reference in New Issue
Block a user