Skip to content

fix(git): keep a change request's state on edited and synchronized events - #659

Merged
pikann merged 1 commit into
Paca-AI:masterfrom
gorlix:fix/git-cr-state-on-edit
Oct 29, 2026
Merged

pikann merged 1 commit into
Paca-AI:masterfrom
gorlix:fix/git-cr-state-on-edit

Conversation

@gorlix

@gorlix gorlix commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

crState now returns the state an event sets (opened/created/reopened -> open, closed, merged) or an empty string when the event leaves the lifecycle unchanged. For those events (edited, synchronized, ready, ...) trackChangeRequest keeps the cached state and merged_at, as review events already do. A request never seen before still defaults to open.

Why

crState returned "open" for every action other than closed/merged, so an edited or synchronized event on a merged or closed MR/PR reset the stored row to open.

Tests

  • New table test: edited after merged stays merged (merged_at kept); synchronized after closed stays closed; reopened after closed/merged becomes open (merged_at cleared); edited on an unseen request becomes open.
  • Updated the existing review test, which relied on synchronized reopening a merged request (now reopened).
  • go vet ./..., go test ./... and golangci-lint on the package pass.

Refs #656

🤖 Generated with Claude Code

…ents

crState returned "open" for every action other than closed/merged, so an
edited or synchronized event on a merged or closed request reset the cached
row to open. Only opened/created/reopened now set open; other actions keep
the cached state (and merged_at), a request never seen defaults to open.

Refs Paca-AI#656

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes

This PR stops a non-lifecycle change-request webhook (edited, synchronized, ready, …) from rewinding a merged or closed row back to open.

  • crState stops defaulting to "open" — services/api/internal/service/git/service.go:426 now returns open only for opened/created/reopened, keeps closed/merged, and returns "" for actions that don't touch the lifecycle.
  • trackChangeRequest preserves the cached state — service.go:367 reads the stored row when the event sets no state and keeps cur.State/cur.MergedAt; a request never seen still defaults to open. This mirrors the existing EventReview branch, and the merged_at clearing on reopen is production-correct (the upsert writes state = EXCLUDED.state, merged_at = EXCLUDED.merged_at).
  • Tests — a new table test covers edited/synchronized/reopened against merged, closed, open and unseen rows, and the review test's reopen case now uses reopened instead of the previously (incorrectly) load-bearing synchronized.

Behavior matches the proposal in #656 item 4, and the added read properly propagates non-ErrNotFound errors so a failed cache update still triggers a platform retry.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pikann pikann 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.

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit b60335c into Paca-AI:master Oct 29, 2026
6 checks passed
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.

2 participants