Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-07-27 20:00:34 +0300
committerPaco Guzman <pacoguzmanp@gmail.com>2016-08-03 08:00:20 +0300
commitc86c1905b5574cac234315598d8d715fcaee3ea7 (patch)
tree31ba7ab51c04b07ea70d15db88f2370f9ca6359e /app/models/compare.rb
parent1d0c7b74920a94e488e6a2c090abb3e525438053 (diff)
switch from diff_file_collection to diffs
So we have raw_diffs too
Diffstat (limited to 'app/models/compare.rb')
-rw-r--r--app/models/compare.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/app/models/compare.rb b/app/models/compare.rb
index 05c8fbbcc36..98c042f3809 100644
--- a/app/models/compare.rb
+++ b/app/models/compare.rb
@@ -1,6 +1,8 @@
class Compare
delegate :same, :head, :base, to: :@compare
+ attr_reader :project
+
def self.decorate(compare, project)
if compare.is_a?(Compare)
compare
@@ -15,49 +17,47 @@ class Compare
end
def commits
- @commits ||= Commit.decorate(@compare.commits, @project)
+ @commits ||= Commit.decorate(@compare.commits, project)
end
def start_commit
return @start_commit if defined?(@start_commit)
commit = @compare.base
- @start_commit = commit ? ::Commit.new(commit, @project) : nil
+ @start_commit = commit ? ::Commit.new(commit, project) : nil
end
- def commit
- return @commit if defined?(@commit)
+ def head_commit
+ return @head_commit if defined?(@head_commit)
commit = @compare.head
- @commit = commit ? ::Commit.new(commit, @project) : nil
- end
- alias_method :head_commit, :commit
-
- # Used only on emails_on_push_worker.rb
- def base_commit=(commit)
- @base_commit = commit
+ @head_commit = commit ? ::Commit.new(commit, project) : nil
end
+ alias_method :commit, :head_commit
def base_commit
return @base_commit if defined?(@base_commit)
- @base_commit = if start_commit && commit
- @project.merge_base_commit(start_commit.id, commit.id)
+ @base_commit = if start_commit && head_commit
+ project.merge_base_commit(start_commit.id, head_commit.id)
else
nil
end
end
- # keyword args until we get ride of diff_refs as argument
- def diff_file_collection(diff_options:, diff_refs: self.diff_refs)
- Gitlab::Diff::FileCollection::Compare.new(@compare,
- project: @project,
+ def raw_diffs(*args)
+ @compare.diffs(*args)
+ end
+
+ def diffs(diff_options:)
+ Gitlab::Diff::FileCollection::Compare.new(self,
+ project: project,
diff_options: diff_options,
diff_refs: diff_refs)
end
def diff_refs
- @diff_refs ||= Gitlab::Diff::DiffRefs.new(
+ Gitlab::Diff::DiffRefs.new(
base_sha: base_commit.try(:sha),
start_sha: start_commit.try(:sha),
head_sha: commit.try(:sha)