diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-20 21:09:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-20 21:09:17 +0000 |
commit | 68f1860e6f1f9e8441c434f4e62238c359ce8c7c (patch) | |
tree | d12eab92b88fdcd0bdcea4586ec5352898b16e6c /app | |
parent | 1af0d38d9c5a88d7123283c714857dc4da991371 (diff) | |
download | gitlab-ce-68f1860e6f1f9e8441c434f4e62238c359ce8c7c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/repository/components/preview/index.vue | 2 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 42 | ||||
-rw-r--r-- | app/views/layouts/nav/_breadcrumbs.html.haml | 2 |
3 files changed, 44 insertions, 2 deletions
diff --git a/app/assets/javascripts/repository/components/preview/index.vue b/app/assets/javascripts/repository/components/preview/index.vue index 99f100eaa60..f96523bb497 100644 --- a/app/assets/javascripts/repository/components/preview/index.vue +++ b/app/assets/javascripts/repository/components/preview/index.vue @@ -56,7 +56,7 @@ export default { </gl-link> </div> </div> - <div class="blob-viewer"> + <div class="blob-viewer" data-qa-selector="blob_viewer_content"> <gl-loading-icon v-if="loading > 0" size="md" color="dark" class="my-4 mx-auto" /> <div v-else-if="readme" ref="readme" v-html="readme.html"></div> </div> diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index fe769573e29..9136c6cc5d4 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -434,8 +434,50 @@ class MergeRequestDiff < ApplicationRecord merge_request_diff_files.reset end + # Transactionally migrate the current merge_request_diff_files entries from + # external storage, back to the database. This is the rollback operation for + # +migrate_files_to_external_storage!+ + # + # If this diff isn't in external storage, the method is a no-op. + def migrate_files_to_database! + return unless stored_externally? + return if merge_request_diff_files.count == 0 + + rows = convert_external_diffs_to_database + + transaction do + MergeRequestDiffFile.where(merge_request_diff_id: id).delete_all + Gitlab::Database.bulk_insert('merge_request_diff_files', rows) + update!(stored_externally: false) + end + + # Only delete the external diff file after the contents have been saved to + # the database + remove_external_diff! + merge_request_diff_files.reset + end + private + def convert_external_diffs_to_database + opening_external_diff do |external_file| + merge_request_diff_files.map do |diff_file| + row = diff_file.attributes.except('diff') + + raise "Diff file lacks external diff offset or size: #{row.inspect}" unless + row['external_diff_offset'] && row['external_diff_size'] + + # The diff in the external file is already base64-encoded if necessary, + # matching the 'binary' attribute of the row. Reading it directly allows + # a cycle of decode-encode to be skipped + external_file.seek(row.delete('external_diff_offset')) + row['diff'] = external_file.read(row.delete('external_diff_size')) + + row + end + end + end + def diffs_in_batch_collection(batch_page, batch_size, diff_options:) Gitlab::Diff::FileCollection::MergeRequestDiffBatch.new(self, batch_page, diff --git a/app/views/layouts/nav/_breadcrumbs.html.haml b/app/views/layouts/nav/_breadcrumbs.html.haml index 1b799477093..c344d3d484f 100644 --- a/app/views/layouts/nav/_breadcrumbs.html.haml +++ b/app/views/layouts/nav/_breadcrumbs.html.haml @@ -7,7 +7,7 @@ = button_tag class: 'toggle-mobile-nav', type: 'button' do %span.sr-only= _("Open sidebar") = icon ('bars') - .breadcrumbs-links.js-title-container + .breadcrumbs-links.js-title-container{ data: { qa_selector: 'breadcrumb_links_content' } } %ul.list-unstyled.breadcrumbs-list.js-breadcrumbs-list - unless hide_top_links = header_title |