diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 21:08:01 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 21:08:01 +0000 |
commit | 561e1b470f0a99fe6304c8f197348c47a637d594 (patch) | |
tree | 6b361b6b0b412b70450aca167079c50a13bd88d8 /lib | |
parent | 7b52c7cb634ef7047d30b0337fe477bcdcedf41d (diff) | |
download | gitlab-ce-561e1b470f0a99fe6304c8f197348c47a637d594.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities/project.rb | 3 | ||||
-rw-r--r-- | lib/api/helpers/projects_helpers.rb | 2 | ||||
-rw-r--r-- | lib/api/lsif_data.rb | 6 | ||||
-rw-r--r-- | lib/api/project_container_repositories.rb | 11 | ||||
-rw-r--r-- | lib/api/projects.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/danger/helper.rb | 3 | ||||
-rw-r--r-- | lib/tasks/cleanup.rake | 33 |
7 files changed, 54 insertions, 5 deletions
diff --git a/lib/api/entities/project.rb b/lib/api/entities/project.rb index 6ed2ed34360..85a00273192 100644 --- a/lib/api/entities/project.rb +++ b/lib/api/entities/project.rb @@ -106,6 +106,9 @@ module API project.auto_devops.nil? ? 'continuous' : project.auto_devops.deploy_strategy end expose :autoclose_referenced_issues + expose :repository_storage, if: ->(project, options) { + Ability.allowed?(options[:current_user], :change_repository_storage, project) + } # rubocop: disable CodeReuse/ActiveRecord def self.preload_relation(projects_relation, options = {}) diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb index c7c9f3ba077..85ed8a4d636 100644 --- a/lib/api/helpers/projects_helpers.rb +++ b/lib/api/helpers/projects_helpers.rb @@ -54,6 +54,7 @@ module API optional :auto_devops_enabled, type: Boolean, desc: 'Flag indication if Auto DevOps is enabled' optional :auto_devops_deploy_strategy, type: String, values: %w(continuous manual timed_incremental), desc: 'Auto Deploy strategy' optional :autoclose_referenced_issues, type: Boolean, desc: 'Flag indication if referenced issues auto-closing is enabled' + optional :repository_storage, type: String, desc: 'Which storage shard the repository is on. Available only to admins' end params :optional_project_params_ee do @@ -125,6 +126,7 @@ module API :wiki_access_level, :avatar, :suggestion_commit_message, + :repository_storage, # TODO: remove in API v5, replaced by *_access_level :issues_enabled, diff --git a/lib/api/lsif_data.rb b/lib/api/lsif_data.rb index 6513973133a..a673ccb4af0 100644 --- a/lib/api/lsif_data.rb +++ b/lib/api/lsif_data.rb @@ -15,7 +15,7 @@ module API resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do segment ':id/commits/:commit_id' do params do - requires :path, type: String, desc: 'The path of a file' + requires :paths, type: Array, desc: 'The paths of the files' end get 'lsif/info' do authorize! :download_code, user_project @@ -30,7 +30,9 @@ module API authorize! :read_pipeline, artifact.job.pipeline file_too_large! if artifact.file.cached_size > MAX_FILE_SIZE - ::Projects::LsifDataService.new(artifact.file, @project, params).execute + service = ::Projects::LsifDataService.new(artifact.file, @project, params[:commit_id]) + + params[:paths].to_h { |path| [path, service.execute(path)] } end end end diff --git a/lib/api/project_container_repositories.rb b/lib/api/project_container_repositories.rb index 70c913bea98..0fd887f4458 100644 --- a/lib/api/project_container_repositories.rb +++ b/lib/api/project_container_repositories.rb @@ -69,7 +69,16 @@ module API end params do requires :repository_id, type: Integer, desc: 'The ID of the repository' - requires :name_regex, type: String, desc: 'The tag name regexp to delete, specify .* to delete all' + optional :name_regex_delete, type: String, desc: 'The tag name regexp to delete, specify .* to delete all' + # require either name_regex (deprecated) or name_regex_delete, it is ok to have both + given name_regex_delete: ->(val) { val.nil? } do + requires :name_regex, type: String, desc: 'The tag name regexp to delete, specify .* to delete all' + end + optional :name_regex, type: String, desc: 'The tag name regexp to delete, specify .* to delete all' + given name_regex: ->(val) { val.nil? } do + requires :name_regex_delete, type: String, desc: 'The tag name regexp to delete, specify .* to delete all' + end + optional :name_regex_keep, type: String, desc: 'The tag name regexp to retain' optional :keep_n, type: Integer, desc: 'Keep n of latest tags with matching name' optional :older_than, type: String, desc: 'Delete older than: 1h, 1d, 1month' end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 43d607bc0c1..f9d08881acf 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -25,6 +25,7 @@ module API end def verify_update_project_attrs!(project, attrs) + attrs.delete(:repository_storage) unless can?(current_user, :change_repository_storage, project) end def delete_project(user_project) diff --git a/lib/gitlab/danger/helper.rb b/lib/gitlab/danger/helper.rb index 3c3f95e5b78..50a68c2e2c4 100644 --- a/lib/gitlab/danger/helper.rb +++ b/lib/gitlab/danger/helper.rb @@ -118,10 +118,9 @@ module Gitlab \.haml-lint_todo.yml | babel\.config\.js | jest\.config\.js | - karma\.config\.js | - webpack\.config\.js | package\.json | yarn\.lock | + config/.+\.js | \.gitlab/ci/frontend\.gitlab-ci\.yml )\z}x => :frontend, diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake new file mode 100644 index 00000000000..8574f26dbdc --- /dev/null +++ b/lib/tasks/cleanup.rake @@ -0,0 +1,33 @@ +namespace :gitlab do + namespace :cleanup do + desc "GitLab | Cleanup | Delete moved repositories" + task moved: :gitlab_environment do + warn_user_is_not_gitlab + remove_flag = ENV['REMOVE'] + + Gitlab.config.repositories.storages.each do |name, repository_storage| + repo_root = repository_storage.legacy_disk_path.chomp('/') + # Look for global repos (legacy, depth 1) and normal repos (depth 2) + IO.popen(%W(find #{repo_root} -mindepth 1 -maxdepth 2 -name *+moved*.git)) do |find| + find.each_line do |path| + path.chomp! + + if remove_flag + if FileUtils.rm_rf(path) + puts "Removed...#{path}".color(:green) + else + puts "Cannot remove #{path}".color(:red) + end + else + puts "Can be removed: #{path}".color(:green) + end + end + end + end + + unless remove_flag + puts "To cleanup these repositories run this command with REMOVE=true".color(:yellow) + end + end + end +end |