summaryrefslogtreecommitdiff
path: root/app/helpers/diff_helper.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/helpers/diff_helper.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/helpers/diff_helper.rb')
-rw-r--r--app/helpers/diff_helper.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
new file mode 100644
index 00000000000..ee4d4fbdff5
--- /dev/null
+++ b/app/helpers/diff_helper.rb
@@ -0,0 +1,22 @@
+module DiffHelper
+ def safe_diff_files(diffs)
+ if diff_hard_limit_enabled?
+ diffs.first(Commit::DIFF_HARD_LIMIT_FILES)
+ else
+ diffs.first(Commit::DIFF_SAFE_FILES)
+ end
+ end
+
+ def show_diff_size_warninig?(diffs)
+ safe_diff_files(diffs).size < diffs.size
+ end
+
+ def diff_hard_limit_enabled?
+ # Enabling hard limit allows user to see more diff information
+ if params[:force_show_diff].present?
+ true
+ else
+ false
+ end
+ end
+end