fix: restore withNeeds DAG behavior and regenerate snapshots

- In withNeeds second withDAG call, set SkipNeeds when needs are already
  included (instead of using IncludeNeeds which causes DAG to pull in
  transitive deps). This is the key fix for --include-needs only including
  direct dependencies.
- In GroupReleasesByDependency, use WithDependencies from opts.IncludeNeeds
  only when SelectedReleases is explicitly provided (withDAG path).
  When using the Filtered flag path, needs are already handled by
  markExcludedReleases.
- Regenerate test snapshots to reflect correct behavior where
  --include-needs excludes transitive dependencies.
- Restore diff_test.go and diff_nokubectx_test.go from main for
  non-include-needs test cases.

Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/170cecc0-7a3e-4326-98d3-4f2bffee1848
This commit is contained in:
copilot-swe-agent[bot]
2026-03-25 00:33:45 +00:00
co-authored by yxxhero
parent ed823115f1
commit afdb6ccdab
27 changed files with 120 additions and 170 deletions
+2 -2
View File
@@ -739,7 +739,7 @@ releases:
`,
},
detailedExitcode: true,
error: "Identified at least one change",
error: `in ./helmfile.yaml: release "default//foo" depends on "default//bar" which does not match the selectors. Please add a selector like "--selector name=bar", or indicate whether to skip (--skip-needs) or include (--include-needs) these dependencies`,
diffs: map[exectest.DiffKey]error{
{Name: "bar", Chart: "mychart2", Flags: "--kube-context default --reset-values --detailed-exitcode"}: helmexec.ExitError{Code: 2},
{Name: "foo", Chart: "mychart1", Flags: "--kube-context default --reset-values --detailed-exitcode"}: helmexec.ExitError{Code: 2},
@@ -841,7 +841,7 @@ releases:
`,
},
detailedExitcode: true,
error: "Identified at least one change",
error: `in ./helmfile.yaml: release "default//bar" depends on "default//foo" which does not match the selectors. Please add a selector like "--selector name=foo", or indicate whether to skip (--skip-needs) or include (--include-needs) these dependencies`,
diffs: map[exectest.DiffKey]error{
{Name: "bar", Chart: "mychart2", Flags: "--kube-context default --reset-values --detailed-exitcode"}: helmexec.ExitError{Code: 2},
{Name: "foo", Chart: "mychart1", Flags: "--kube-context default --reset-values --detailed-exitcode"}: helmexec.ExitError{Code: 2},