Skip to content

fix: git commit status not reflecting in promotion strategy#1110

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-49503628-784266290-4ac79e67-be4d-40fe-85f2-507238d30017
Draft

fix: git commit status not reflecting in promotion strategy#1110
Copilot wants to merge 3 commits intomainfrom
copilot/fix-49503628-784266290-4ac79e67-be4d-40fe-85f2-507238d30017

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

When a GitCommitStatus evaluates to success for a new proposed SHA (without a phase transition from non-success), the corresponding ChangeTransferPolicy is not re-enqueued directly by the GCS controller.

Root Cause

GitCommitStatus controller — missing CTP enqueue on SHA-only transitions

touchChangeTransferPolicies only fires when phase transitions from non-success → success:

if previousPhase != string(promoterv1alpha1.CommitPhaseSuccess) && phase == string(promoterv1alpha1.CommitPhaseSuccess) {
    transitionedEnvironments = append(transitionedEnvironments, branch)
}

When a new proposed SHA arrives and the expression still evaluates to success (no phase change), transitionedEnvironments stays empty and the CTP is never directly enqueued. The CommitStatus controller's SHA-based fallback path can miss the CTP if it hasn't yet reconciled for the new SHA at the time the fallback runs.

Changes

  • gitcommitstatus_controller.go: Extend transitionedEnvironments to also capture environments where the proposed SHA changed while the phase remains success, so touchChangeTransferPolicies reliably enqueues the CTP after any meaningful state change.
  • gitcommitstatus_controller_test.go: Add integration test "GitCommitStatus SHA-only transition enqueues CTP" — two environments with AutoMerge=true and a GitCommitStatus with expression: "true" — that verifies both CTPs auto-merge for a first commit and again for a second commit (the SHA-only transition case).
Original prompt

a recently reported issue about a git status not reflecting in a promotion strategy


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@crenshaw-dev
Copy link
Contributor

Commit status controllers are supposed to require either the PS or CTP (I forget which) after state transitions. This is documented in best practices. Maybe the git controller isnt doing that correctly.

Work in a test drive way. Start with a test that tries to reproduce the issue with just a git status. If that doesn't reproduce the issue, use an argocd health check too, like in the issue.

A failing test that fails for the right reason is better than nothing. But try to also find the fix.

@crenshaw-dev
Copy link
Contributor

@copilot see last comment

Copilot AI changed the title [WIP] a recently reported issue about a git status not reflecting in a promotion strategy fix: git commit status not reflecting in promotion strategy Feb 26, 2026
@crenshaw-dev
Copy link
Contributor

@copilot try again

@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.56%. Comparing base (92728b3) to head (d453183).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1110      +/-   ##
==========================================
+ Coverage   50.41%   50.56%   +0.14%     
==========================================
  Files          51       51              
  Lines        5492     5496       +4     
==========================================
+ Hits         2769     2779      +10     
+ Misses       2417     2415       -2     
+ Partials      306      302       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copilot AI and others added 2 commits February 26, 2026 12:31
…stays success

Co-authored-by: crenshaw-dev <350466+crenshaw-dev@users.noreply.github.com>
Co-authored-by: crenshaw-dev <350466+crenshaw-dev@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot try again

Addressed in d453183.

Root cause: processEnvironments only added an environment to transitionedEnvironments when the phase transitioned from non-success → success. For a second commit where the expression still evaluates to success (no phase change), touchChangeTransferPolicies was never called, so the CTP wasn't directly enqueued by the GCS controller.

Fix: Extended the condition to also trigger CTP enqueue when the phase is success AND the proposed SHA changed. This makes the GCS controller directly enqueue the CTP for any meaningful state change rather than relying solely on the CommitStatus controller's SHA-based lookup path as a fallback.

Test: Added "GitCommitStatus SHA-only transition enqueues CTP" — two environments with AutoMerge=true, a GitCommitStatus with expression: "true", makes two commits in sequence, and asserts that both CTPs auto-merge for each commit.

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