Class: CodeQualia::GitAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/code_qualia/git_analyzer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(days = 90) ⇒ GitAnalyzer

Returns a new instance of GitAnalyzer.



13
14
15
# File 'lib/code_qualia/git_analyzer.rb', line 13

def initialize(days = 90)
  @days = days
end

Class Method Details

.analyze(days = 90) ⇒ Object



9
10
11
# File 'lib/code_qualia/git_analyzer.rb', line 9

def self.analyze(days = 90)
  new(days).analyze
end

Instance Method Details

#analyzeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/code_qualia/git_analyzer.rb', line 17

def analyze
  Logger.log("Checking if current directory is a git repository")
  
  unless git_repository?
    Logger.log("Not a git repository, skipping git analysis")
    return {}
  end

  Logger.log("Git repository detected, analyzing #{@days} days of history")
  config = ConfigHelper.load_config
  git_log_output = run_git_log
  Logger.log("Git log retrieved, parsing file changes")
  
  result = parse_git_log(git_log_output, config)
  Logger.log("Found git history for #{result.size} files")
  result
rescue StandardError => e
  Logger.log_error('Git analysis', e)
  raise Error, "Failed to analyze git history: #{e.message}"
end