diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-15 12:18:19 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-23 15:37:05 -0500 |
commit | 7e09a9b7dcef125af2e775869754a3327935b12d (patch) | |
tree | fe9392e26107c717111498aacd515dcafcadd7d1 /app/helpers/diff_helper.rb | |
parent | 2830cb923742dc32d790f1ec369a98f816c47067 (diff) | |
download | gitlab-ce-7e09a9b7dcef125af2e775869754a3327935b12d.tar.gz |
Clean up diff rendering
Diffstat (limited to 'app/helpers/diff_helper.rb')
-rw-r--r-- | app/helpers/diff_helper.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index da5838247a6..4cfaa103741 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -102,16 +102,32 @@ module DiffHelper ].join(' ').html_safe end - def commit_for_diff(diff_file) - return diff_file.content_commit if diff_file.content_commit + def diff_content_commit(diff_file) + content_commit = diff_file.content_commit + return content_commit if content_commit - if diff_file.deleted_file - @base_commit || @commit.parent || @commit + if diff_file.deleted_file? + diff_old_content_commit(diff_file) else @commit end end + def diff_old_content_commit(diff_file) + return if diff_file.new_file? + + diff_file.old_content_commit || @base_commit || @commit.parent || @commit + end + + def diff_file_blob_raw_path(diff_file) + namespace_project_raw_path(@project.namespace, @project, tree_join(diff_content_commit(diff_file).sha, diff_file.file_path)) + end + + def diff_file_old_blob_raw_path(diff_file) + return if diff_file.new_file? + namespace_project_raw_path(@project.namespace, @project, tree_join(diff_old_content_commit(diff_file).sha, diff_file.old_path)) + end + def diff_file_html_data(project, diff_file_path, diff_commit_id) { blob_diff_path: namespace_project_blob_diff_path(project.namespace, project, |