diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/file.js | 15 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/mutations/file.js | 22 | ||||
-rw-r--r-- | app/assets/javascripts/repository/utils/readme.js | 45 | ||||
-rw-r--r-- | app/models/project_ci_cd_setting.rb | 1 | ||||
-rw-r--r-- | app/services/concerns/spam_check_methods.rb (renamed from app/services/spam_check_service.rb) | 6 | ||||
-rw-r--r-- | app/services/create_snippet_service.rb | 2 | ||||
-rw-r--r-- | app/services/issues/create_service.rb | 2 | ||||
-rw-r--r-- | app/services/issues/update_service.rb | 2 | ||||
-rw-r--r-- | app/services/update_snippet_service.rb | 2 |
9 files changed, 58 insertions, 39 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js index cec4ce204f8..99e13e32ba4 100644 --- a/app/assets/javascripts/ide/stores/actions/file.js +++ b/app/assets/javascripts/ide/stores/actions/file.js @@ -61,8 +61,10 @@ export const getFileData = ( { path, makeFileActive = true, openFile = makeFileActive }, ) => { const file = state.entries[path]; + const fileDeletedAndReadded = getters.isFileDeletedAndReadded(path); - if (file.raw || (file.tempFile && !file.prevPath)) return Promise.resolve(); + if (file.raw || (file.tempFile && !file.prevPath && !fileDeletedAndReadded)) + return Promise.resolve(); commit(types.TOGGLE_LOADING, { entry: file }); @@ -102,11 +104,16 @@ export const setFileMrChange = ({ commit }, { file, mrChange }) => { export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) => { const file = state.entries[path]; + const stagedFile = state.stagedFiles.find(f => f.path === path); + return new Promise((resolve, reject) => { + const fileDeletedAndReadded = getters.isFileDeletedAndReadded(path); service - .getRawFileData(file) + .getRawFileData(fileDeletedAndReadded ? stagedFile : file) .then(raw => { - if (!(file.tempFile && !file.prevPath)) commit(types.SET_FILE_RAW_DATA, { file, raw }); + if (!(file.tempFile && !file.prevPath && !fileDeletedAndReadded)) + commit(types.SET_FILE_RAW_DATA, { file, raw, fileDeletedAndReadded }); + if (file.mrChange && file.mrChange.new_file === false) { const baseSha = (getters.currentMergeRequest && getters.currentMergeRequest.baseCommitSha) || ''; @@ -151,7 +158,7 @@ export const changeFileContent = ({ commit, dispatch, state }, { path, content } if (file.changed && indexOfChangedFile === -1) { commit(types.ADD_FILE_TO_CHANGED, path); - } else if (!file.changed && indexOfChangedFile !== -1) { + } else if (!file.changed && !file.tempFile && indexOfChangedFile !== -1) { commit(types.REMOVE_FILE_FROM_CHANGED, path); } diff --git a/app/assets/javascripts/ide/stores/mutations/file.js b/app/assets/javascripts/ide/stores/mutations/file.js index 73d03e57f54..313fa1fe029 100644 --- a/app/assets/javascripts/ide/stores/mutations/file.js +++ b/app/assets/javascripts/ide/stores/mutations/file.js @@ -54,27 +54,29 @@ export default { } }); }, - [types.SET_FILE_RAW_DATA](state, { file, raw }) { + [types.SET_FILE_RAW_DATA](state, { file, raw, fileDeletedAndReadded = false }) { const openPendingFile = state.openFiles.find( - f => f.path === file.path && f.pending && !(f.tempFile && !f.prevPath), + f => + f.path === file.path && f.pending && !(f.tempFile && !f.prevPath && !fileDeletedAndReadded), ); + const stagedFile = state.stagedFiles.find(f => f.path === file.path); - if (file.tempFile && file.content === '') { - Object.assign(state.entries[file.path], { - content: raw, - }); + if (file.tempFile && file.content === '' && !fileDeletedAndReadded) { + Object.assign(state.entries[file.path], { content: raw }); + } else if (fileDeletedAndReadded) { + Object.assign(stagedFile, { raw }); } else { - Object.assign(state.entries[file.path], { - raw, - }); + Object.assign(state.entries[file.path], { raw }); } if (!openPendingFile) return; if (!openPendingFile.tempFile) { openPendingFile.raw = raw; - } else if (openPendingFile.tempFile) { + } else if (openPendingFile.tempFile && !fileDeletedAndReadded) { openPendingFile.content = raw; + } else if (fileDeletedAndReadded) { + Object.assign(stagedFile, { raw }); } }, [types.SET_FILE_BASE_RAW_DATA](state, { file, baseRaw }) { diff --git a/app/assets/javascripts/repository/utils/readme.js b/app/assets/javascripts/repository/utils/readme.js index e43b2bdc33a..ef4162f4463 100644 --- a/app/assets/javascripts/repository/utils/readme.js +++ b/app/assets/javascripts/repository/utils/readme.js @@ -1,21 +1,32 @@ -const MARKDOWN_EXTENSIONS = ['mdown', 'mkd', 'mkdn', 'md', 'markdown']; -const ASCIIDOC_EXTENSIONS = ['adoc', 'ad', 'asciidoc']; -const OTHER_EXTENSIONS = ['textile', 'rdoc', 'org', 'creole', 'wiki', 'mediawiki', 'rst']; -const EXTENSIONS = [...MARKDOWN_EXTENSIONS, ...ASCIIDOC_EXTENSIONS, ...OTHER_EXTENSIONS]; -const PLAIN_FILENAMES = ['readme', 'index']; -const FILE_REGEXP = new RegExp( - `^(${PLAIN_FILENAMES.join('|')})(.(${EXTENSIONS.join('|')}))?$`, - 'i', -); -const PLAIN_FILE_REGEXP = new RegExp(`^(${PLAIN_FILENAMES.join('|')})`, 'i'); -const EXTENSIONS_REGEXP = new RegExp(`.(${EXTENSIONS.join('|')})$`, 'i'); +const FILENAMES = ['index', 'readme']; -// eslint-disable-next-line import/prefer-default-export -export const readmeFile = blobs => { - const readMeFiles = blobs.filter(f => f.name.search(FILE_REGEXP) !== -1); +const MARKUP_EXTENSIONS = [ + 'ad', + 'adoc', + 'asciidoc', + 'creole', + 'markdown', + 'md', + 'mdown', + 'mediawiki', + 'mkd', + 'mkdn', + 'org', + 'rdoc', + 'rst', + 'textile', + 'wiki', +]; - const previewableReadme = readMeFiles.find(f => f.name.search(EXTENSIONS_REGEXP) !== -1); - const plainReadme = readMeFiles.find(f => f.name.search(PLAIN_FILE_REGEXP) !== -1); +const isRichReadme = file => { + const re = new RegExp(`^(${FILENAMES.join('|')})\\.(${MARKUP_EXTENSIONS.join('|')})$`, 'i'); + return re.test(file.name); +}; - return previewableReadme || plainReadme; +const isPlainReadme = file => { + const re = new RegExp(`^(${FILENAMES.join('|')})$`, 'i'); + return re.test(file.name); }; + +// eslint-disable-next-line import/prefer-default-export +export const readmeFile = blobs => blobs.find(isRichReadme) || blobs.find(isPlainReadme); diff --git a/app/models/project_ci_cd_setting.rb b/app/models/project_ci_cd_setting.rb index b292d39dae7..1dd65c76258 100644 --- a/app/models/project_ci_cd_setting.rb +++ b/app/models/project_ci_cd_setting.rb @@ -4,7 +4,6 @@ class ProjectCiCdSetting < ApplicationRecord include IgnorableColumns # https://gitlab.com/gitlab-org/gitlab/issues/36651 ignore_column :merge_trains_enabled, remove_with: '12.7', remove_after: '2019-12-22' - belongs_to :project, inverse_of: :ci_cd_settings # The version of the schema that first introduced this model/table. diff --git a/app/services/spam_check_service.rb b/app/services/concerns/spam_check_methods.rb index 51d300d4f1d..a0945857f89 100644 --- a/app/services/spam_check_service.rb +++ b/app/services/concerns/spam_check_methods.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -# SpamCheckService +# SpamCheckMethods # # Provide helper methods for checking if a given spammable object has # potential spam data. # # Dependencies: # - params with :request -# -module SpamCheckService + +module SpamCheckMethods # rubocop:disable Gitlab/ModuleWithInstanceVariables def filter_spam_check_params @request = params.delete(:request) diff --git a/app/services/create_snippet_service.rb b/app/services/create_snippet_service.rb index eacea7d94c7..56c175ebdb1 100644 --- a/app/services/create_snippet_service.rb +++ b/app/services/create_snippet_service.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class CreateSnippetService < BaseService - include SpamCheckService + include SpamCheckMethods def execute filter_spam_check_params diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 8d1df0d87a7..e8879d4df66 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -2,7 +2,7 @@ module Issues class CreateService < Issues::BaseService - include SpamCheckService + include SpamCheckMethods include ResolveDiscussions def execute diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb index b98a4d2567f..68d1657d881 100644 --- a/app/services/issues/update_service.rb +++ b/app/services/issues/update_service.rb @@ -2,7 +2,7 @@ module Issues class UpdateService < Issues::BaseService - include SpamCheckService + include SpamCheckMethods def execute(issue) handle_move_between_ids(issue) diff --git a/app/services/update_snippet_service.rb b/app/services/update_snippet_service.rb index ac7f8e9b1f5..d365e4e7b2b 100644 --- a/app/services/update_snippet_service.rb +++ b/app/services/update_snippet_service.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class UpdateSnippetService < BaseService - include SpamCheckService + include SpamCheckMethods attr_accessor :snippet |