Class: ClaudeMemory::Commands::GitLfsCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/claude_memory/commands/git_lfs_command.rb

Overview

Sets up git-lfs tracking for the project memory database. This allows committing .claude/memory.sqlite3 to a git repository without bloating the repo, using Git Large File Storage.

Constant Summary collapse

TRACKED_PATTERN =
".claude/memory.sqlite3"

Instance Attribute Summary

Attributes inherited from BaseCommand

#stderr, #stdin, #stdout

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Constructor Details

This class inherits a constructor from ClaudeMemory::Commands::BaseCommand

Instance Method Details

#call(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/claude_memory/commands/git_lfs_command.rb', line 11

def call(args)
  opts = parse_options(args, {compact: true}) do |o|
    OptionParser.new do |parser|
      parser.banner = "Usage: claude-memory git-lfs [options]"
      parser.on("--no-compact", "Skip compacting before setup") { o[:compact] = false }
    end
  end
  return 1 if opts.nil?

  return failure("Not a git repository. Run this from a project root.") unless git_repo?
  return failure("git-lfs is not installed. Install it first: https://git-lfs.com") unless git_lfs_installed?

  if already_tracked?
    stdout.puts "git-lfs is already tracking #{TRACKED_PATTERN}"
    return 0
  end

  if opts[:compact]
    stdout.puts "Compacting project database before setup..."
    compact_project_db
  end

  setup_git_lfs
  0
end