fix(cli): run gitignore-tracked warning before dirty-check so it fires unconditionally
This commit is contained in:
parent
137a50c932
commit
ab465ef07c
@ -298,6 +298,18 @@ func newPluginPublishCmd() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
// Run the tracked-yet-gitignored warning BEFORE the dirty check so
|
||||
// the developer sees it even on the aborted-publish path; the spec
|
||||
// asks for this warning to be unconditional.
|
||||
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)")
|
||||
}
|
||||
|
||||
if !allowDirty {
|
||||
out, _ := exec.Command("git", "status", "--porcelain").Output()
|
||||
if len(strings.TrimSpace(string(out))) > 0 {
|
||||
@ -316,15 +328,6 @@ 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)")
|
||||
}
|
||||
|
||||
// `git archive` does not recurse into submodules, so any submodule
|
||||
// paths will appear as empty directories in the tarball. Detect via
|
||||
// .gitmodules so this works even for submodules that haven't been
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user