summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-15 18:28:21 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-15 18:28:21 +0300
commitbe5b6db883ee634dc53e0a50ac57f424507d7a7d (patch)
tree9f4c78713e823b09b2d293f0a9dd7179358d8917 /app/models/commit.rb
parent3dc347a369783f2a1fec3b6cc724a9b41a43283c (diff)
downloadgitlab-ce-be5b6db883ee634dc53e0a50ac57f424507d7a7d.tar.gz
Refactor diff suppress logic and diff views
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb27
1 files changed, 2 insertions, 25 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 82876e10446..ff5392957ce 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -12,6 +12,7 @@ class Commit
# User can force display of diff above this size
DIFF_SAFE_FILES = 100
DIFF_SAFE_LINES = 5000
+
# Commits above this size will not be rendered in HTML
DIFF_HARD_LIMIT_FILES = 1000
DIFF_HARD_LIMIT_LINES = 50000
@@ -23,23 +24,7 @@ class Commit
# Calculate number of lines to render for diffs
def diff_line_count(diffs)
- diffs.reduce(0){|sum, d| sum + d.diff.lines.count}
- end
-
- def diff_suppress?(diffs, line_count = nil)
- # optimize - check file count first
- return true if diffs.size > DIFF_SAFE_FILES
-
- line_count ||= Commit::diff_line_count(diffs)
- line_count > DIFF_SAFE_LINES
- end
-
- def diff_force_suppress?(diffs, line_count = nil)
- # optimize - check file count first
- return true if diffs.size > DIFF_HARD_LIMIT_FILES
-
- line_count ||= Commit::diff_line_count(diffs)
- line_count > DIFF_HARD_LIMIT_LINES
+ diffs.reduce(0) { |sum, d| sum + d.diff.lines.count }
end
end
@@ -60,14 +45,6 @@ class Commit
@diff_line_count
end
- def diff_suppress?
- Commit::diff_suppress?(self.diffs, diff_line_count)
- end
-
- def diff_force_suppress?
- Commit::diff_force_suppress?(self.diffs, diff_line_count)
- end
-
# Returns a string describing the commit for use in a link title
#
# Example