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-26 10:21:42 +0300
committerPaco Guzman <pacoguzmanp@gmail.com>2016-08-03 08:00:20 +0300
commit8f359ea9170b984ad43d126e17628c31ac3a1f14 (patch)
treeee47d5172537ddedabc2cc38ef3cb5bf966c89ee /app/models/compare.rb
parentcd7c2cb6ddd4d9c9f9bdae00c887c0022c121c17 (diff)
Move to Gitlab::Diff::FileCollection
Instead calling diff_collection.count use diff_collection.size which is cache on the diff_collection
Diffstat (limited to 'app/models/compare.rb')
-rw-r--r--app/models/compare.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/compare.rb b/app/models/compare.rb
new file mode 100644
index 00000000000..6672d1bf059
--- /dev/null
+++ b/app/models/compare.rb
@@ -0,0 +1,23 @@
+class Compare
+ delegate :commits, :same, :head, :base, to: :@compare
+
+ def self.decorate(compare, project)
+ if compare.is_a?(Compare)
+ compare
+ else
+ self.new(compare, project)
+ end
+ end
+
+ def initialize(compare, project)
+ @compare = compare
+ @project = project
+ end
+
+ def diff_file_collection(diff_options:, diff_refs: nil)
+ Gitlab::Diff::FileCollection::Compare.new(@compare,
+ project: @project,
+ diff_options: diff_options,
+ diff_refs: diff_refs)
+ end
+end