Refuse to deploy from a stale or dirty working copy - #24
Merged
Conversation
Update-Production.ps1 publishes whatever is in the local working copy.
Merging a PR on the remote does not update that copy, so a checkout left
behind origin publishes pre-fix code while reporting a clean, successful
deployment — which is exactly how a merged drawer fix reached production
without taking effect.
Adds Assert-SourceUpToDate, run before any publish:
- blocks on uncommitted changes (published output would match no commit)
- blocks when the branch is behind its origin counterpart
- warns on unpushed local commits, and prints the revision being deployed
- degrades to a warning when git is unavailable, the tree is not a repo,
detached HEAD, or origin is unreachable — none of these should hard-block
Skipped for -RestartOnly (no publish occurs) and overridable with
-SkipGitCheck, which is forwarded to elevated and per-server child
invocations so the check runs once in the parent.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Update-Production.ps1publishes whatever is in the local working copy. Merging a PR on the remote does not update that copy, so a checkout left behindoriginpublishes pre-fix code while reporting a clean, successful deployment.That is not hypothetical — it is how the merged drawer fix in #22 reached production without taking effect. The deploy was correct; the source wasn't.
What
Assert-SourceUpToDate, run before any publish:Skipped for
-RestartOnly(nothing is published). Overridable with-SkipGitCheck, which is forwarded to elevated and per-server child invocations so the check runs once in the parent rather than per server.Testing
Function extracted and exercised against real repo states:
git pull --ff-onlyremedy-SkipGitCheckScript parses clean (
[Parser]::ParseFile, 0 errors). Test scaffolding removed.Note this file is not itself deployed — it is the thing doing the deploying, so the guard takes effect on the next run after merge.
🤖 Generated with Claude Code