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:
@@ -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 {
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user