Class: FindChangedFiles

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

Direct Known Subclasses

BetweenRefs, SimpleDiff, SinceRef

Defined Under Namespace

Classes: BetweenRefs, SimpleDiff, SinceRef

Constant Summary collapse

GIT_DIFF_COMMAND =
'git diff'.freeze
GIT_DIFF_OPTIONS =
'--name-only'.freeze
REDIRECT_STDERR_TO_STDOUT =
'2>&1'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_ref: nil, diff_ref: nil) ⇒ FindChangedFiles

Returns a new instance of FindChangedFiles.



15
16
17
18
# File 'lib/find_changed_files.rb', line 15

def initialize(base_ref: nil, diff_ref: nil)
  @base_ref = base_ref
  @diff_ref = diff_ref
end

Instance Attribute Details

#base_refObject (readonly)

Returns the value of attribute base_ref.



8
9
10
# File 'lib/find_changed_files.rb', line 8

def base_ref
  @base_ref
end

#diff_refObject (readonly)

Returns the value of attribute diff_ref.



8
9
10
# File 'lib/find_changed_files.rb', line 8

def diff_ref
  @diff_ref
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/find_changed_files.rb', line 20

def call
  if simple_diff?
    SimpleDiff.new.call
  elsif since_ref?
    SinceRef.new(
      base_ref: base_ref
    ).call
  elsif between_refs?
    BetweenRefs.new(
      base_ref: base_ref,
      diff_ref: diff_ref
    ).call
  else
    raise ArgumentError.new('A base ref must be supplied with a diff ref')
  end
end