Class: ContextCommitsDiff

Inherits:
Object
  • Object
show all
Includes:
ActsAsPaginatedDiff
Defined in:
app/models/context_commits_diff.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ActsAsPaginatedDiff

#diffs_in_batch

Constructor Details

#initialize(merge_request) ⇒ ContextCommitsDiff

Returns a new instance of ContextCommitsDiff.


9
10
11
# File 'app/models/context_commits_diff.rb', line 9

def initialize(merge_request)
  @merge_request = merge_request
end

Instance Attribute Details

#merge_requestObject (readonly)

Returns the value of attribute merge_request.


7
8
9
# File 'app/models/context_commits_diff.rb', line 7

def merge_request
  @merge_request
end

Instance Method Details

#commits_countObject


17
18
19
# File 'app/models/context_commits_diff.rb', line 17

def commits_count
  merge_request.context_commits_count
end

#diff_refsObject


34
35
36
37
38
39
# File 'app/models/context_commits_diff.rb', line 34

def diff_refs
  Gitlab::Diff::DiffRefs.new(
    base_sha: commits.last&.diff_refs&.base_sha,
    head_sha: commits.first&.diff_refs&.head_sha
  )
end

#diffs(diff_options = nil) ⇒ Object


21
22
23
24
25
26
27
28
# File 'app/models/context_commits_diff.rb', line 21

def diffs(diff_options = nil)
  Gitlab::Diff::FileCollection::Compare.new(
    self,
    project: merge_request.project,
    diff_options: diff_options,
    diff_refs: diff_refs
  )
end

#empty?Boolean

Returns:

  • (Boolean)

13
14
15
# File 'app/models/context_commits_diff.rb', line 13

def empty?
  commits.empty?
end

#raw_diffs(options = {}) ⇒ Object


30
31
32
# File 'app/models/context_commits_diff.rb', line 30

def raw_diffs(options = {})
  compare.diffs(options.merge(paths: paths))
end