Skip to content

Commit 9e551c0

Browse files
committed
Remove helper functions
1 parent 73945d8 commit 9e551c0

File tree

2 files changed

+0
-68
lines changed

2 files changed

+0
-68
lines changed

cmd/kustomize-build-dirs/main.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -127,35 +127,6 @@ func checkKustomizeInstalled() error {
127127
return nil
128128
}
129129

130-
// splitPath takes a full file path string and returns a slice of its directory components.
131-
// It extracts the directory portion of the path and splits it by forward slashes (/).
132-
// Example: "aaa/bbb/ccc/file.yaml" => ["aaa", "bbb", "ccc"]
133-
func splitPath(path string) []string {
134-
cleaned := filepath.ToSlash(filepath.Dir(path))
135-
if cleaned == "." {
136-
return []string{}
137-
}
138-
return strings.Split(cleaned, "/")
139-
}
140-
141-
// commonPrefix compares two string slices (representing directory segments)
142-
// and returns their longest shared prefix.
143-
// Example: ["aaa", "bbb", "ccc"], ["aaa", "bbb", "ddd"] => ["aaa", "bbb"]
144-
func commonPrefix(a, b []string) []string {
145-
minLen := len(a)
146-
if len(b) < minLen {
147-
minLen = len(b)
148-
}
149-
out := make([]string, 0, minLen)
150-
for i := 0; i < minLen; i++ {
151-
if a[i] != b[i] {
152-
break
153-
}
154-
out = append(out, a[i])
155-
}
156-
return out
157-
}
158-
159130
// deepestCommonDirs takes a list of file paths and returns a list of directory paths
160131
// that represent the deepest common directory for each group of similarly prefixed files
161132
// with a minimum directory depth enforced.

cmd/kustomize-build-dirs/main_test.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -477,45 +477,6 @@ resources:
477477
compareResults(t, outDir, expectedContents, readOutDir(t, outDir))
478478
}
479479

480-
func TestSplitPath(t *testing.T) {
481-
tests := []struct {
482-
input string
483-
expected []string
484-
}{
485-
{"file.yaml", []string{}},
486-
{"aaa/bbb/file.yaml", []string{"aaa", "bbb"}},
487-
{"aaa/bbb/ccc/file.yaml", []string{"aaa", "bbb", "ccc"}},
488-
{"./aaa/bbb/ccc/file.yaml", []string{"aaa", "bbb", "ccc"}},
489-
}
490-
491-
for _, tt := range tests {
492-
t.Run(tt.input, func(t *testing.T) {
493-
got := splitPath(tt.input)
494-
require.Equal(t, tt.expected, got)
495-
})
496-
}
497-
}
498-
499-
func TestCommonPrefix(t *testing.T) {
500-
tests := []struct {
501-
a, b []string
502-
expected []string
503-
}{
504-
{[]string{}, []string{"aaa"}, []string{}},
505-
{[]string{"aaa"}, []string{}, []string{}},
506-
{[]string{"aaa", "bbb"}, []string{"aaa", "bbb"}, []string{"aaa", "bbb"}},
507-
{[]string{"aaa", "bbb"}, []string{"ccc", "ddd"}, []string{}},
508-
{[]string{"aaa", "bbb", "ccc"}, []string{"aaa", "bbb", "ddd"}, []string{"aaa", "bbb"}},
509-
}
510-
511-
for _, tt := range tests {
512-
t.Run("", func(t *testing.T) {
513-
got := commonPrefix(tt.a, tt.b)
514-
require.Equal(t, tt.expected, got)
515-
})
516-
}
517-
}
518-
519480
func TestDeepestCommonDirs(t *testing.T) {
520481
tests := []struct {
521482
name string

0 commit comments

Comments
 (0)