Skip to content

fix(appdir): include multi-source apps when any source matches the branch - #548

Open
nidiodolfini wants to merge 1 commit into
zapier:mainfrom
nidiodolfini:fix/shouldinclude-multisource-detection
Open

nidiodolfini wants to merge 1 commit into
zapier:mainfrom
nidiodolfini:fix/shouldinclude-multisource-detection

Conversation

@nidiodolfini

Copy link
Copy Markdown

Problem

shouldInclude (pkg/appdir/app_directory.go) drops multi-source Applications whose first source is a versioned Helm chart.

getTargetRevision(app) returns app.Spec.GetSource().TargetRevision, which for a multi-source app is Sources[0]. A common ArgoCD multi-source layout is:

  • source[0]: an OCI/Helm chart with targetRevision: <chart version> (e.g. 0.5.13) and helm.valueFiles: ["$values/…"]
  • source[1]: a git ref source (ref: values, targetRevision: <branch>) providing the values

When a PR changes the values file in the git repo, the affected app is correctly matched by the change list, but then excluded: shouldInclude compares the chart's version (0.5.13) against the PR's target branch (main) and returns false. Result: No affected apps or appsets, skipping.

Fix

Iterate all sources; include the app if any source's targetRevision matches the branch (or is empty / HEAD). This lets chart-first multi-source apps be checked when their git values source targets the PR branch. Single-source behavior is unchanged.

Verified against a live ArgoCD instance where a .argocd/values.yaml PR now correctly produces a diff comment (previously "No changes").

…anch

getTargetRevision reads only Sources[0]; a chart-first multi-source app (OCI
chart pinned in source[0], values in a git ref source) was excluded because
the chart's targetRevision (a version) never equals the PR target branch.
shouldInclude now iterates all sources.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes app inclusion filtering for ArgoCD multi-source Applications in pkg/appdir, ensuring apps are not incorrectly excluded from PR checks when the first source is a versioned Helm chart but a later git/values source targets the PR branch.

Changes:

  • Update shouldInclude to iterate over all application sources and include the app if any source matches the target branch (or is empty / HEAD with main/master handling).
  • Add clarifying comments documenting the multi-source “chart-first + git values ref” scenario and the prior exclusion behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +124 to +125
for _, source := range getSources(app) {
targetRevision := source.TargetRevision
Comment on lines 118 to +124
func shouldInclude(app v1alpha1.Application, targetBranch string) bool {
targetRevision := getTargetRevision(app)
if targetRevision == "" {
return true
}

if targetRevision == targetBranch {
return true
}

if targetRevision == "HEAD" {
if targetBranch == "main" {
// Consider every source: a multi-source Application whose values live in a
// git source (targetRevision=<branch>) must be included even when the first
// source is a versioned Helm chart (targetRevision=<chart version>).
// getTargetRevision(app) only reads app.Spec.GetSource() == Sources[0], so
// "chart-first" multi-source apps were incorrectly excluded from PR checks.
for _, source := range getSources(app) {
@Greyeye

Greyeye commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

@nidiodolfini, please write a unit test covering both single-source and multi-source.
Also, would you be able to review the Copilot's comment?

@Greyeye Greyeye self-assigned this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants