From 84ca6a8d1c05d99e938bff032fbcf09ade38a4f9 Mon Sep 17 00:00:00 2001 From: typebasedio Date: Fri, 10 Apr 2026 14:42:01 -0400 Subject: [PATCH] feat(v0.3): run git init and ensure .gitignore for project workspaces After Create() returns, project mode now: 1. Runs git init (or prints "git not found; skipped..." if git is unavailable) 2. Calls EnsureGitignore, which is a no-op when a seed already supplied .gitignore (preserving the seed-wins rule end-to-end) Both git unavailability and git init failure are non-fatal: ctask warns and continues, so a missing/broken git toolchain never blocks project creation. --- cmd/new.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/new.go b/cmd/new.go index baf9f31..09b3f3a 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "os" "github.com/spf13/cobra" "github.com/warrenronsiek/ctask/internal/config" @@ -97,6 +98,20 @@ func runNew(cmd *cobra.Command, args []string) error { return err } + if newProject { + if !workspace.GitAvailable() { + fmt.Println("[ctask] git not found; skipped repository initialization") + } else { + if err := workspace.RunGitInit(ws.Path); err != nil { + fmt.Fprintf(os.Stderr, "[ctask] warning: %v\n", err) + } + } + // Seed-wins: EnsureGitignore is a no-op when a seed provided .gitignore. + if err := workspace.EnsureGitignore(ws.Path); err != nil { + fmt.Fprintf(os.Stderr, "[ctask] warning: failed to create .gitignore: %v\n", err) + } + } + relPath := workspace.RelativePath(root, ws.Path) fmt.Printf("[ctask] created %s\n", relPath)