diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index 0ae6c876..3c1314b6 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -767,13 +767,9 @@ func (t *Testing) ComputeChangedChartDirectories() ([]string, error) { dir := filepath.Dir(file) // Make sure directory is really a chart directory chartDir, err := t.utils.LookupChartDir(cfg.ChartDirs, dir) - chartDirElement := strings.Split(chartDir, "/") if err == nil { - if len(chartDirElement) > 1 { - chartDirName := chartDirElement[len(chartDirElement)-1] - if slices.Contains(cfg.ExcludedCharts, chartDirName) { - continue - } + if slices.Contains(cfg.ExcludedCharts, filepath.Base(chartDir)) { + continue } changedChartFiles[chartDir] = append(changedChartFiles[chartDir], strings.TrimPrefix(file, chartDir+"/")) } else { diff --git a/pkg/chart/chart_test.go b/pkg/chart/chart_test.go index 2b3246fa..243c01e4 100644 --- a/pkg/chart/chart_test.go +++ b/pkg/chart/chart_test.go @@ -199,6 +199,18 @@ func TestComputeChangedChartDirectoriesWithHelmignore(t *testing.T) { assert.ElementsMatch(t, expected, actual) } +func TestComputeChangedChartDirectoriesWithExcludedChartAtRoot(t *testing.T) { + cfg := config.Configuration{ + ExcludedCharts: []string{"excluded", "test_chart_at_root"}, + ChartDirs: []string{"test_charts", "."}, + } + ct := newTestingMock(cfg) + actual, err := ct.ComputeChangedChartDirectories() + expected := []string{"test_charts/foo", "test_charts/bar"} + assert.Nil(t, err) + assert.ElementsMatch(t, expected, actual) +} + func TestComputeChangedChartDirectoriesWithMultiLevelChart(t *testing.T) { cfg := config.Configuration{ ExcludedCharts: []string{"excluded"},