fix(skills): stop publish --fix from publishing

When --fix is used, return early after applying fixes instead of
continuing to the publish flow. The fixed files need to be committed
before publishing, so proceeding would fail anyway since the repo
would not be in sync.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Sam Morrow 2026-04-20 12:22:55 +02:00
parent 61a7865380
commit 2e64043d55
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View file

@ -126,7 +126,8 @@ func NewCmdPublish(f *cmdutil.Factory, runF func(*PublishOptions) error) *cobra.
Use %[1]s--dry-run%[1]s to validate without publishing.
Use %[1]s--tag%[1]s to publish non-interactively with a specific tag.
Use %[1]s--fix%[1]s to automatically strip install metadata from committed files.
Use %[1]s--fix%[1]s to automatically strip install metadata from committed files
without publishing. Review and commit the changes, then run publish again.
`, "`"),
Example: heredoc.Doc(`
# Validate and publish interactively
@ -138,7 +139,7 @@ func NewCmdPublish(f *cmdutil.Factory, runF func(*PublishOptions) error) *cobra.
# Validate only (no publish)
$ gh skill publish --dry-run
# Validate and strip install metadata
# Strip install metadata without publishing
$ gh skills publish --fix
`),
Args: cobra.MaximumNArgs(1),
@ -153,7 +154,7 @@ func NewCmdPublish(f *cmdutil.Factory, runF func(*PublishOptions) error) *cobra.
},
}
cmd.Flags().BoolVar(&opts.Fix, "fix", false, "Auto-fix issues where possible (e.g. strip install metadata)")
cmd.Flags().BoolVar(&opts.Fix, "fix", false, "Auto-fix issues where possible without publishing (e.g. strip install metadata)")
cmd.Flags().BoolVar(&opts.DryRun, "dry-run", false, "Validate without publishing")
cmd.Flags().StringVar(&opts.Tag, "tag", "", "Version tag for the release (e.g. v1.0.0)")
@ -410,6 +411,15 @@ func publishRun(opts *PublishOptions) error {
return nil
}
if opts.Fix {
if fixes > 0 {
fmt.Fprintf(opts.IO.ErrOut, "\nFixed %d file(s). Review and commit the changes, then run %s to publish.\n", fixes, "gh skills publish")
} else {
fmt.Fprintf(opts.IO.ErrOut, "\nNo issues to fix.\n")
}
return nil
}
if owner == "" || repo == "" {
fmt.Fprintf(opts.IO.ErrOut, "\nValidation passed. Set up a GitHub remote to publish.\n")
return nil

View file

@ -457,6 +457,7 @@ func TestPublishRun(t *testing.T) {
return &PublishOptions{IO: ios, Dir: dir, Fix: true}
},
wantStdout: "stripped install metadata",
wantStderr: "Fixed 1 file(s). Review and commit the changes",
verify: func(t *testing.T, dir string) {
t.Helper()
fixed, err := os.ReadFile(filepath.Join(dir, "skills", "test-skill", "SKILL.md"))