From c3cfa18ae07dc3abb5108009473402b382501ecb Mon Sep 17 00:00:00 2001 From: Alex Dunmow Date: Wed, 3 Jun 2026 08:56:43 +0800 Subject: [PATCH] fix(cli): warn about untracked files when publishing with --allow-dirty `git stash create` only captures tracked content, so a developer using --allow-dirty after creating new files (but forgetting to `git add`) would ship a tarball missing them with no indication. Now publish lists the untracked, non-ignored files to stderr and suggests `git add` when --allow-dirty is in play. Co-Authored-By: Claude Opus 4.7 --- cmd/ninja/cmd/plugin.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/ninja/cmd/plugin.go b/cmd/ninja/cmd/plugin.go index 689e9df..240977c 100644 --- a/cmd/ninja/cmd/plugin.go +++ b/cmd/ninja/cmd/plugin.go @@ -303,6 +303,17 @@ func newPluginPublishCmd() *cobra.Command { if len(strings.TrimSpace(string(out))) > 0 { return fmt.Errorf("working tree dirty; commit or pass --allow-dirty") } + } else { + // `git stash create` only captures tracked content, so untracked + // files would be silently dropped from the archive. Warn loudly. + out, _ := exec.Command("git", "ls-files", "--others", "--exclude-standard").Output() + if names := strings.TrimSpace(string(out)); names != "" { + fmt.Fprintln(os.Stderr, "warning: --allow-dirty: these untracked files will NOT be in the archive:") + for _, n := range strings.Split(names, "\n") { + fmt.Fprintln(os.Stderr, " "+n) + } + fmt.Fprintln(os.Stderr, " (run `git add ` if they should be shipped)") + } } out, _ := exec.Command("git", "ls-files", "--cached", "--ignored", "--exclude-standard").Output()