Skip to content

fix(events): make undiverged honor module autoplanning#6428

Merged
chenrui333 merged 6 commits into
runatlantis:mainfrom
krewenki:main
Apr 29, 2026
Merged

fix(events): make undiverged honor module autoplanning#6428
chenrui333 merged 6 commits into
runatlantis:mainfrom
krewenki:main

Conversation

@krewenki
Copy link
Copy Markdown
Contributor

what

  • Make targeted undiverged checks use Atlantis project-impact resolution instead of only matching base branch changes against raw autoplan.when_modified patterns.
  • Reuse the existing configured-project and autodiscovery logic so default branch divergence is evaluated the same way Atlantis decides whether a project is impacted.
  • Add the WorkingDir.GetDivergedFiles() path needed to map base branch changes to impacted projects.
  • Update the undiverged docs and add focused coverage around module and autodiscovery cases.

why

  • The old targeted undiverged behavior could miss relevant base branch changes when a project was impacted through module autoplanning rather than a direct file match.
  • That made the undiverged gate less accurate than Atlantis's own project selection logic, which is not a great split.
  • This change keeps the gate aligned with the rest of Atlantis instead of reimplementing a simpler matcher in a separate path.
  • If project-impact resolution cannot determine the answer, it falls back to a full divergence check so the behavior stays conservative.

tests

  • I added unit coverage for configured-project module changes, autodiscovered project impacts, unrelated changes, and resolver-error fallback behavior.
  • I ran GOCACHE=/tmp/go-build go test ./server/events/...
  • I verified the server package still compiles with GOCACHE=/tmp/go-build go test ./server -run '^$'

references

  • No linked issue.
  • Docs updated in this PR: runatlantis.io/docs/command-requirements.md

* 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>
Copilot AI review requested due to automatic review settings April 24, 2026 17:54
@dosubot dosubot Bot added feature New functionality/enhancement go Pull requests that update Go code labels Apr 24, 2026
@github-actions github-actions Bot added the docs Documentation label Apr 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 UndivergedProjectImpactResolver and wires it into DefaultCommandRequirementHandler for targeted undiverged checks.
  • Extends WorkingDir with GetDivergedFiles() 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.

Comment thread server/events/undiverged_project_impact.go
Comment thread server/events/undiverged_project_impact.go Outdated
Signed-off-by: Rui Chen <rui@chenrui.dev>
@chenrui333 chenrui333 changed the title fix(events): make undiverged honor module autoplanning (#1) fix(events): make undiverged honor module autoplanning Apr 29, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 29, 2026
@chenrui333 chenrui333 merged commit 3b39a00 into runatlantis:main Apr 29, 2026
17 of 18 checks passed
@chenrui333
Copy link
Copy Markdown
Member

Thanks @krewenki for your first contribution to Atlantis!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation feature New functionality/enhancement go Pull requests that update Go code lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants