feat(cli): warn at publish when tracked files match .gitignore

This commit is contained in:
Alex Dunmow 2026-06-03 01:35:04 +08:00
parent c825942c8d
commit 57a217f54d

View File

@ -235,6 +235,15 @@ func newPluginPublishCmd() *cobra.Command {
}
}
out, _ := exec.Command("git", "ls-files", "--cached", "--ignored", "--exclude-standard").Output()
if names := strings.TrimSpace(string(out)); names != "" {
fmt.Fprintln(os.Stderr, "warning: these tracked files match .gitignore and will still be shipped:")
for _, n := range strings.Split(names, "\n") {
fmt.Fprintln(os.Stderr, " "+n)
}
fmt.Fprintln(os.Stderr, " (run `git rm --cached <file>` to drop)")
}
archiveBytes, err := archive.BuildSourceArchive(".")
if err != nil {
return fmt.Errorf("build archive: %w", err)