Class: FilesInMyDiff::Git::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/files_in_my_diff/git/diff.rb

Instance Method Summary collapse

Constructor Details

#initialize(object:, revision:) ⇒ Diff

Returns a new instance of Diff.



6
7
8
9
# File 'lib/files_in_my_diff/git/diff.rb', line 6

def initialize(object:, revision:)
  @object = object
  @revision = revision
end

Instance Method Details

#changesObject



19
20
21
22
23
24
25
26
# File 'lib/files_in_my_diff/git/diff.rb', line 19

def changes
  parent = @object.parents.first
  return [] if parent.nil?

  parent.diff(@object).map do |change|
    { path: change.path, type: change.type }
  end
end

#shaObject



15
16
17
# File 'lib/files_in_my_diff/git/diff.rb', line 15

def sha
  @object.sha
end

#validate!Object

Raises:



11
12
13
# File 'lib/files_in_my_diff/git/diff.rb', line 11

def validate!
  raise ValidationError, "Revision #{@revision} does not exist" if @object.nil?
end