Class: FilesInMyDiff::Git::Diff
- Inherits:
-
Object
- Object
- FilesInMyDiff::Git::Diff
- Defined in:
- lib/files_in_my_diff/git/diff.rb
Instance Method Summary collapse
- #changes ⇒ Object
-
#initialize(object:, revision:) ⇒ Diff
constructor
A new instance of Diff.
- #sha ⇒ Object
- #validate! ⇒ Object
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
#changes ⇒ Object
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 |
#sha ⇒ Object
15 16 17 |
# File 'lib/files_in_my_diff/git/diff.rb', line 15 def sha @object.sha end |
#validate! ⇒ Object
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 |