Class: Evilution::Git::ChangedFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/git/changed_files.rb

Constant Summary collapse

MAIN_BRANCHES =
%w[main master origin/main origin/master].freeze
SOURCE_PREFIXES =
%w[lib/ app/].freeze

Instance Method Summary collapse

Instance Method Details

#callObject

Raises:



11
12
13
14
15
16
17
18
19
20
# File 'lib/evilution/git/changed_files.rb', line 11

def call
  main_branch = detect_main_branch
  merge_base = run_git("merge-base", "HEAD", main_branch)
  diff_output = run_git("diff", "--name-only", "--diff-filter=ACMR", "#{merge_base}..HEAD")

  files = diff_output.split("\n").select { |f| ruby_source_file?(f) }
  raise Evilution::Error, "no changed Ruby files found since merge base with #{main_branch}" if files.empty?

  files
end