Class: Evilution::Git::ChangedFiles Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

MAIN_BRANCHES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

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

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%w[lib/ app/].freeze

Instance Method Summary collapse

Instance Method Details

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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