Create .gitignore in sgard init to exclude blobs/ from git.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 22:26:34 -07:00
parent db9aa7bbff
commit caf1698c16
2 changed files with 13 additions and 0 deletions

View File

@@ -46,6 +46,11 @@ func Init(root string) (*Garden, error) {
return nil, fmt.Errorf("creating store: %w", err) return nil, fmt.Errorf("creating store: %w", err)
} }
gitignorePath := filepath.Join(absRoot, ".gitignore")
if err := os.WriteFile(gitignorePath, []byte("blobs/\n"), 0o644); err != nil {
return nil, fmt.Errorf("creating .gitignore: %w", err)
}
clk := clockwork.NewRealClock() clk := clockwork.NewRealClock()
m := manifest.NewWithTime(clk.Now().UTC()) m := manifest.NewWithTime(clk.Now().UTC())
if err := m.Save(manifestPath); err != nil { if err := m.Save(manifestPath); err != nil {

View File

@@ -25,6 +25,14 @@ func TestInitCreatesStructure(t *testing.T) {
t.Errorf("blobs/ not found: %v", err) t.Errorf("blobs/ not found: %v", err)
} }
// .gitignore should exist and exclude blobs/
gitignore, err := os.ReadFile(filepath.Join(repoDir, ".gitignore"))
if err != nil {
t.Errorf(".gitignore not found: %v", err)
} else if string(gitignore) != "blobs/\n" {
t.Errorf(".gitignore content = %q, want %q", gitignore, "blobs/\n")
}
if g.manifest.Version != 1 { if g.manifest.Version != 1 {
t.Errorf("expected version 1, got %d", g.manifest.Version) t.Errorf("expected version 1, got %d", g.manifest.Version)
} }