Class: Henitai::GitDiffAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/henitai/git_diff_analyzer.rb

Overview

Shells out to git to discover changed files between two refs.

By default the analyzer runs in the current working directory. Callers can pass dir: to point it at another repository root without changing cwd.

Instance Method Summary collapse

Instance Method Details

#changed_files(from:, to:, dir: Dir.pwd) ⇒ Object

Raises:



14
15
16
17
18
19
20
# File 'lib/henitai/git_diff_analyzer.rb', line 14

def changed_files(from:, to:, dir: Dir.pwd)
  stdout, stderr, status = git_diff(dir, "--name-only", from, to)

  raise GitDiffError, stderr.strip unless status.success?

  stdout.split("\n").reject(&:empty?)
end

#changed_methods(from:, to:, dir: Dir.pwd) ⇒ Object



22
23
24
25
26
# File 'lib/henitai/git_diff_analyzer.rb', line 22

def changed_methods(from:, to:, dir: Dir.pwd)
  changed_files(from:, to:, dir:).flat_map do |path|
    changed_methods_in_file(path, from:, to:, dir:)
  end
end