Skip to content

feat: Automatically create .gitignore in .same directory #65

@drlucaa

Description

@drlucaa

To ensure build artifacts and local caches are not accidentally committed to version control, same should automatically initialize a .gitignore file within its internal metadata directory (.same/). This follows the "Reliable" and "Simple" brand pillars by providing sensible, secure defaults without requiring manual user intervention.

The implementation will reside in the internal/adapters/cas layer, ensuring that whenever a new Content Addressable Store is initialized, the corresponding ignore rules are also established.

Goals

  • Prevent Data Leakage: Automatically exclude the local store/ and cache/ directories from Git.
  • Centralized Configuration: Utilize the existing internal/core/domain/layout.go to define the .gitignore path and filename.
  • Idempotent Execution: Ensure the file is only created if it does not already exist, allowing for potential future user overrides.

Acceptance Criteria

  1. Domain Definition: internal/core/domain/layout.go contains a constant for .gitignore and a helper function DefaultGitIgnorePath().
  2. Automatic Creation: When cas.NewStore() or cas.NewStoreWithPath() is called and creates the directory, it also writes a .gitignore file if one is missing.
  3. File Content: The generated .gitignore contains exactly the following lines:
store/
cache/

  1. Hermetic Verification:
  • nix develop -c go test -race ./cli/internal/adapters/cas/... passes with new assertions.
  • nix develop -c golangci-lint run ./cli/... passes without violations.
  1. Unit Tests: Existing tests in store_test.go are updated to verify the physical presence and content of the .gitignore file after initialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions