fix(events): make undiverged honor module autoplanning (#1)#6428
fix(events): make undiverged honor module autoplanning (#1)#6428krewenki wants to merge 1 commit intorunatlantis:mainfrom
Conversation
* fix: make undiverged honor module autoplanning Teach targeted undiverged checks to reuse Atlantis autoplanning impact resolution, including module dependencies and autodiscovered projects. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: Warren Krewenki <19960+krewenki@users.noreply.github.com> * chore(events): clarify diverged file logging Signed-off-by: Warren Krewenki <19960+krewenki@users.noreply.github.com> * fix(events): address PR review feedback\n\nSigned-off-by: Warren Krewenki <19960+krewenki@users.noreply.github.com> * fix(events): fall back to full undiverged check on resolver errors\n\nSigned-off-by: Warren Krewenki <19960+krewenki@users.noreply.github.com> --------- Signed-off-by: Warren Krewenki <19960+krewenki@users.noreply.github.com> Co-authored-by: OpenAI Codex <noreply@openai.com>
There was a problem hiding this comment.
Pull request overview
Aligns targeted undiverged command requirement behavior with Atlantis’s project selection logic so that default-branch divergence is evaluated based on actual project impact (including module autoplanning and autodiscovery), rather than only raw when_modified glob matching.
Changes:
- Introduces an
UndivergedProjectImpactResolverand wires it intoDefaultCommandRequirementHandlerfor targetedundivergedchecks. - Extends
WorkingDirwithGetDivergedFiles()and refactors targeted divergence checks to reuse that logic. - Adds focused unit tests for configured-project module impacts, autodiscovery impacts, unrelated changes, and resolver-error fallback; updates docs accordingly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/server.go | Reuses a shared DefaultProjectFinder and wires the new impact resolver into the command requirement handler. |
| server/events/working_dir.go | Adds GetDivergedFiles() to WorkingDir and refactors targeted divergence checks to use shared diverged-file lookup. |
| server/events/command_requirement_handler.go | Adds resolver hook for targeted undiverged, with conservative fallback to full divergence check on errors. |
| server/events/undiverged_project_impact.go | Implements impact resolution mirroring Atlantis project selection (configured + autodiscovery + module autoplanning). |
| server/events/undiverged_project_impact_test.go | Adds unit coverage for module/autodiscovery impact scenarios and fallback behavior. |
| server/events/mocks/mock_working_dir.go | Updates generated mock to include GetDivergedFiles(). |
| server/events/mock_workingdir_test.go | Updates generated in-package mock to include GetDivergedFiles(). |
| runatlantis.io/docs/command-requirements.md | Documents updated targeted undiverged behavior and conservative fallback semantics. |
| divergedFiles, err := workingDir.GetDivergedFiles(ctx.Log, repoDir, ctx.Pull) | ||
| if err != nil { | ||
| return true, false, err | ||
| } | ||
|
|
||
| impacted, err = r.impactedByModifiedFiles(ctx, repoDir, target, divergedFiles) | ||
| if err != nil { | ||
| return true, false, err | ||
| } | ||
|
|
||
| return true, impacted, nil |
There was a problem hiding this comment.
HasUndivergedImpact always calls impactedByModifiedFiles (which runs FindModuleProjects) even when GetDivergedFiles returns no changed files. This adds unnecessary module-scanning overhead on every command when the base branch hasn’t diverged (and also when CheckoutMerge is disabled and GetDivergedFiles returns nil). Consider early-returning handled=true, impacted=false when len(divergedFiles)==0 to avoid the extra work.
what
undivergedchecks use Atlantis project-impact resolution instead of only matching base branch changes against rawautoplan.when_modifiedpatterns.WorkingDir.GetDivergedFiles()path needed to map base branch changes to impacted projects.undivergeddocs and add focused coverage around module and autodiscovery cases.why
undivergedbehavior could miss relevant base branch changes when a project was impacted through module autoplanning rather than a direct file match.undivergedgate less accurate than Atlantis's own project selection logic, which is not a great split.tests
GOCACHE=/tmp/go-build go test ./server/events/...serverpackage still compiles withGOCACHE=/tmp/go-build go test ./server -run '^$'references
runatlantis.io/docs/command-requirements.md