summaryrefslogtreecommitdiff
path: root/app/helpers/diff_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/diff_helper.rb')
-rw-r--r--app/helpers/diff_helper.rb23
1 files changed, 21 insertions, 2 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 1bd3ec5e0e0..b896fba3704 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -137,7 +137,7 @@ module DiffHelper
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
- link_to url_for(params_copy), id: "commit-diff-viewtype", class: (params[:view] != 'parallel' ? 'btn btn-sm active' : 'btn btn-sm') do
+ link_to url_for(params_copy), id: "inline-diff-btn", class: (params[:view] != 'parallel' ? 'btn btn-sm active' : 'btn btn-sm') do
'Inline'
end
end
@@ -148,7 +148,7 @@ module DiffHelper
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
- link_to url_for(params_copy), id: "commit-diff-viewtype", class: (params[:view] == 'parallel' ? 'btn active btn-sm' : 'btn btn-sm') do
+ link_to url_for(params_copy), id: "parallel-diff-btn", class: (params[:view] == 'parallel' ? 'btn active btn-sm' : 'btn btn-sm') do
'Side-by-side'
end
end
@@ -167,4 +167,23 @@ module DiffHelper
content_tag(:span, commit_id, class: 'monospace'),
].join(' ').html_safe
end
+
+ def commit_for_diff(diff)
+ if diff.deleted_file
+ @merge_request ? @merge_request.commits.last : @commit.parents.first
+ else
+ @commit
+ end
+ end
+
+ def diff_file_html_data(project, diff_commit, diff_file)
+ {
+ blob_diff_path: namespace_project_blob_diff_path(project.namespace, project,
+ tree_join(diff_commit.id, diff_file.file_path))
+ }
+ end
+
+ def editable_diff?(diff)
+ !diff.deleted_file && @merge_request && @merge_request.source_project
+ end
end