on main help sign in
chore: update generated `.crush/.gitignore` to not ignore skills
1a0b638Andrey Nering
.crush/.gitignorenew file+5
@@ -0,0 +1,5 @@
1+# This file is automatically generated by Crush.
2+*
3+!.gitignore
4+!skills/
5+!skills/**
internal/cmd/gitignore/defaultnew file+5
@@ -0,0 +1,5 @@
1+# This file is automatically generated by Crush.
2+*
3+!.gitignore
4+!skills/
5+!skills/**
internal/cmd/gitignore/oldnew file+1
@@ -0,0 +1 @@
1+*
internal/cmd/root.go+12−2
@@ -3,6 +3,7 @@ package cmd
3import (
3import (
4 "bytes"
4 "bytes"
5 "context"
5 "context"
6+ _ "embed"
6 "errors"
7 "errors"
7 "fmt"
8 "fmt"
8 "io"
9 "io"
@@ -305,11 +306,20 @@ func createDotCrushDir(dir string) error {
305 }
306 }
306
307
307 gitIgnorePath := filepath.Join(dir, ".gitignore")
308 gitIgnorePath := filepath.Join(dir, ".gitignore")
308− if _, err := os.Stat(gitIgnorePath); os.IsNotExist(err) {
309+ content, err := os.ReadFile(gitIgnorePath)
310+
311+ // create or update if old version
312+ if os.IsNotExist(err) || string(content) == oldGitIgnore {
309− if err := os.WriteFile(gitIgnorePath, []byte("*\n"), 0o644); err != nil {
313+ if err := os.WriteFile(gitIgnorePath, []byte(defaultGitIgnore), 0o644); err != nil {
310 return fmt.Errorf("failed to create .gitignore file: %q %w", gitIgnorePath, err)
314 return fmt.Errorf("failed to create .gitignore file: %q %w", gitIgnorePath, err)
311 }
315 }
312 }
316 }
313
317
314 return nil
318 return nil
315}
319}
320+
321+//go:embed gitignore/old
322+var oldGitIgnore string
323+
324+//go:embed gitignore/default
325+var defaultGitIgnore string