feat: let every environment toggle default-branch tracking from its comment - #242
Conversation
…omment The "Redeploy on pushes to default branches" option was only rendered once it was already enabled, so it could be turned off from the pull request comment but never on. Render it for every active environment instead. Because an absent option line previously meant "off", parsing now returns undefined when the line is missing so a stale or hand-trimmed comment body no longer clears the stored value. Comment overrides are applied before a redeploy request is honoured, so a single edit that changes options and ticks Redeploy keeps both, and a body that cannot be parsed no longer swallows the redeploy. Also hides the option on torn down environments and adds trackDefaultBranches to the build API schema.
Reading the option used two separate whole-body scans, so a quoted copy of the line could be read as checked while the real list item was unchecked. It is now a single match with a capture group, and quoted lines no longer count because GitHub does not render those as checkboxes. Moving overrides ahead of the redeploy also let a cache purge request take precedence over a redeploy request in the same edit, which dropped the redeploy. Redeploy comes first again. The option is now hidden only for torn down environments, matching the actions block, instead of also hiding while tearing down. The test covering the absent-option guard passed even with the guard removed, because an undefined value is ignored when matching call arguments. It now asserts the key is absent, and fails without the guard.
|
Raising a finding from review that I have deliberately not changed, because it touches a design decision made in #241 rather than anything this PR introduced. The stale-comment window
const queued = await this.enqueueRedeployIfEnabled(updatedBuild, pullRequest, runUuid);
if (!queued) {
await refreshMissionControlComment(this, updatedBuild, pullRequest);
}So when a redeploy is queued — the common case — the comment keeps showing the previous value until a build or deploy status transition rebuilds it. During that window, anyone editing the comment for an unrelated reason submits a body carrying the old value, and it gets written back. This PR makes that window matter more than it did. Previously the option line rendered only when the setting was enabled, so a stale body preserved The absent-line guard added here does not help: it returns Why I left it aloneSkipping the refresh when a redeploy is queued is deliberate and covered by two tests ( Options, roughly in order of size
Happy to implement whichever you prefer, in this PR or a follow-up. |
What
The Redeploy on pushes to default branches option now appears as a checkbox in the environment comment for every active environment.
Previously it was only rendered once already enabled, so it could be switched off from the comment but never on. In practice that meant it could only be set from the CLI.
Behaviour
Also
trackDefaultBranchesis added to the build API schema. The endpoint already returned it; only the schema was missing it, so clients could not type it.Testing
Parser coverage for the checked, unchecked and absent cases, and for bodies that should not match. Ordering coverage for comment edits that request several things at once.