chore: update generated `.crush/.gitignore` to not ignore skills

Andrey Nering created

Change summary

.crush/.gitignore              |  5 +++++
internal/cmd/gitignore/default |  5 +++++
internal/cmd/gitignore/old     |  1 +
internal/cmd/root.go           | 14 ++++++++++++--
4 files changed, 23 insertions(+), 2 deletions(-)

Detailed changes

.crush/.gitignore 🔗

@@ -0,0 +1,5 @@
+# This file is automatically generated by Crush.
+*
+!.gitignore
+!skills/
+!skills/**

internal/cmd/root.go 🔗

@@ -3,6 +3,7 @@ package cmd
 import (
 	"bytes"
 	"context"
+	_ "embed"
 	"errors"
 	"fmt"
 	"io"
@@ -305,11 +306,20 @@ func createDotCrushDir(dir string) error {
 	}
 
 	gitIgnorePath := filepath.Join(dir, ".gitignore")
-	if _, err := os.Stat(gitIgnorePath); os.IsNotExist(err) {
-		if err := os.WriteFile(gitIgnorePath, []byte("*\n"), 0o644); err != nil {
+	content, err := os.ReadFile(gitIgnorePath)
+
+	// create or update if old version
+	if os.IsNotExist(err) || string(content) == oldGitIgnore {
+		if err := os.WriteFile(gitIgnorePath, []byte(defaultGitIgnore), 0o644); err != nil {
 			return fmt.Errorf("failed to create .gitignore file: %q %w", gitIgnorePath, err)
 		}
 	}
 
 	return nil
 }
+
+//go:embed gitignore/old
+var oldGitIgnore string
+
+//go:embed gitignore/default
+var defaultGitIgnore string