Repository navigation
fix: add diff -fail-on gate and report added prompts as new - #7
Merged
Merged
Conversation
promptctl diff exited 0 whatever the verdict, so CI had to grep for "=> structural", and a prompt added since the ref was diffed against an empty file and reported as "structural". diff now takes -fail-on, a comma-separated list of verdicts (new, structural, tweak, minor). It prints the full diff and exits 1 if any prompt's verdict is in the list. Without the flag the exit code is 0 as before. A prompt absent from the ref now reads "=> new". Flags may come before or after the ref. Fixes #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 18, 2026
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.
What was wrong
promptctl diffalways exited 0, so CI had to grep the output for=> structuralto gate a change.structuralinstead ofnew.The fix
-fail-on(also--fail-on): a comma-separated list of verdicts (new,structural,tweak,minor).diffstill prints the full diff, then exits 1 if any prompt's verdict is in the list and names the matching prompts on stderr. Without the flag the exit code stays 0 (backward compatible). An unknown verdict name exits 2, like other flag errors.new prompt (not in <ref>)/=> newinstead of a fake insert hunk that always readsstructural.promptctl diff origin/main -fail-on structural).runDiff, which returns each prompt's verdict (semdiff.Worstof its hunks), so it can be tested in-process.Tests
New
cmd/promptctl/diff_test.go:TestRunDiffVerdicts(real go-git repo: a rewrite readsstructural, an added prompt readsnew),TestRunDiffNoChanges, andTestParseFailOn.With the
newbranch disabled, the test fails as on main:Full suite:
GOWORK=off go build ./... && go vet ./... && go test ./...→ok github.com/priompt/cli/cmd/promptctlBefore / after (real run, offline lexical embedder)
Repo with one committed prompt rewritten and one new prompt.
Before (main):
After:
Fixes #3
🤖 Generated with Claude Code