Skip to content

Commit d6d7d8e

Browse files
authored
Merge pull request #379 from nanobox-io/hotfix/duplicate-paths
remove duplicate paths from the etc exports
2 parents 16bd00d + e8887bc commit d6d7d8e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

util/provider/share/share_darwin.go

+26
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,31 @@ func cleanLine(line, lineCheck string) string {
181181
}
182182
goodPaths = append(goodPaths, path)
183183
}
184+
goodPaths = removeDuplicates(goodPaths)
184185
return fmt.Sprintf("\"%s\" %s", strings.Join(goodPaths, "\" \""), lineCheck)
185186
}
187+
188+
// takes a set of paths and removes duplicates as well as cleaning up any child paths
189+
func removeDuplicates(paths []string) []string {
190+
rtn := []string{}
191+
// look through the paths
192+
for i, path := range paths {
193+
194+
for j, originalPath := range paths {
195+
196+
// if im looking at the same path then ignore it
197+
if i == j {
198+
continue
199+
}
200+
201+
// if i find an element that is shorter but the same directory structure
202+
// ignore the child directory
203+
if strings.HasPrefix(path, originalPath) {
204+
continue
205+
}
206+
207+
rtn = append(rtn, path)
208+
}
209+
}
210+
return rtn
211+
}

0 commit comments

Comments
 (0)