diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 18:09:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 18:09:24 +0000 |
commit | 619d0b6922a6cf95d291fbbf5fa3d09e772a1ea8 (patch) | |
tree | fb8f8e036cec1b32166206bb5102af6c5dca8cfe /app | |
parent | 17ab40ca089e1aef61a83f77ab6df62a72f6ce06 (diff) | |
download | gitlab-ce-619d0b6922a6cf95d291fbbf5fa3d09e772a1ea8.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/commits_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/repositories/git_http_controller.rb | 2 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 2 | ||||
-rw-r--r-- | app/models/repository.rb | 1 | ||||
-rw-r--r-- | app/services/groups/import_export/export_service.rb | 16 | ||||
-rw-r--r-- | app/services/groups/import_export/import_service.rb | 2 | ||||
-rw-r--r-- | app/services/lfs/lock_file_service.rb | 4 | ||||
-rw-r--r-- | app/services/lfs/unlock_file_service.rb | 4 | ||||
-rw-r--r-- | app/services/projects/import_export/export_service.rb | 22 |
9 files changed, 30 insertions, 26 deletions
diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 15bb35dd0be..b161e44660e 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -64,10 +64,13 @@ class Projects::CommitsController < Projects::ApplicationController render_404 unless @path.empty? || request.format == :atom || @repository.blob_at(@commit.id, @path) || @repository.tree(@commit.id, @path).entries.present? @limit, @offset = (params[:limit] || 40).to_i, (params[:offset] || 0).to_i search = params[:search] + author = params[:author] @commits = if search.present? @repository.find_commits_by_message(search, @ref, @path, @limit, @offset) + elsif author.present? + @repository.commits(@ref, author: author, path: @path, limit: @limit, offset: @offset) else @repository.commits(@ref, path: @path, limit: @limit, offset: @offset) end diff --git a/app/controllers/repositories/git_http_controller.rb b/app/controllers/repositories/git_http_controller.rb index 75c79881264..5c2b6089bff 100644 --- a/app/controllers/repositories/git_http_controller.rb +++ b/app/controllers/repositories/git_http_controller.rb @@ -7,7 +7,7 @@ module Repositories before_action :access_check prepend_before_action :deny_head_requests, only: [:info_refs] - rescue_from Gitlab::GitAccess::UnauthorizedError, with: :render_403_with_exception + rescue_from Gitlab::GitAccess::ForbiddenError, with: :render_403_with_exception rescue_from Gitlab::GitAccess::NotFoundError, with: :render_404_with_exception rescue_from Gitlab::GitAccess::ProjectCreationError, with: :render_422_with_exception rescue_from Gitlab::GitAccess::TimeoutError, with: :render_503_with_exception diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 4ae64b6c8f1..869a2e8da20 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -599,7 +599,7 @@ module Ci # Manually set the notes for a Ci::Pipeline # There is no ActiveRecord relation between Ci::Pipeline and notes # as they are related to a commit sha. This method helps importing - # them using the +Gitlab::ImportExport::ProjectRelationFactory+ class. + # them using the +Gitlab::ImportExport::Project::RelationFactory+ class. def notes=(notes) notes.each do |note| note[:id] = nil diff --git a/app/models/repository.rb b/app/models/repository.rb index cddffa9bb1d..a53850bb068 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -139,6 +139,7 @@ class Repository repo: raw_repository, ref: ref, path: opts[:path], + author: opts[:author], follow: Array(opts[:path]).length == 1, limit: opts[:limit], offset: opts[:offset], diff --git a/app/services/groups/import_export/export_service.rb b/app/services/groups/import_export/export_service.rb index 2c3975961a8..aa484e7203c 100644 --- a/app/services/groups/import_export/export_service.rb +++ b/app/services/groups/import_export/export_service.rb @@ -18,6 +18,8 @@ module Groups end save! + ensure + cleanup end private @@ -28,7 +30,7 @@ module Groups if savers.all?(&:save) notify_success else - cleanup_and_notify_error! + notify_error! end end @@ -37,21 +39,19 @@ module Groups end def tree_exporter - Gitlab::ImportExport::GroupTreeSaver.new(group: @group, current_user: @current_user, shared: @shared, params: @params) + Gitlab::ImportExport::Group::TreeSaver.new(group: @group, current_user: @current_user, shared: @shared, params: @params) end def file_saver Gitlab::ImportExport::Saver.new(exportable: @group, shared: @shared) end - def cleanup_and_notify_error - FileUtils.rm_rf(shared.export_path) - - notify_error + def cleanup + FileUtils.rm_rf(shared.archive_path) if shared&.archive_path end - def cleanup_and_notify_error! - cleanup_and_notify_error + def notify_error! + notify_error raise Gitlab::ImportExport::Error.new(shared.errors.to_sentence) end diff --git a/app/services/groups/import_export/import_service.rb b/app/services/groups/import_export/import_service.rb index 628c8f5bac0..57d2d9855d1 100644 --- a/app/services/groups/import_export/import_service.rb +++ b/app/services/groups/import_export/import_service.rb @@ -34,7 +34,7 @@ module Groups end def restorer - @restorer ||= Gitlab::ImportExport::GroupTreeRestorer.new(user: @current_user, + @restorer ||= Gitlab::ImportExport::Group::TreeRestorer.new(user: @current_user, shared: @shared, group: @group, group_hash: nil) diff --git a/app/services/lfs/lock_file_service.rb b/app/services/lfs/lock_file_service.rb index 383a0d6b4e3..1b283018c16 100644 --- a/app/services/lfs/lock_file_service.rb +++ b/app/services/lfs/lock_file_service.rb @@ -4,13 +4,13 @@ module Lfs class LockFileService < BaseService def execute unless can?(current_user, :push_code, project) - raise Gitlab::GitAccess::UnauthorizedError, 'You have no permissions' + raise Gitlab::GitAccess::ForbiddenError, 'You have no permissions' end create_lock! rescue ActiveRecord::RecordNotUnique error('already locked', 409, current_lock) - rescue Gitlab::GitAccess::UnauthorizedError => ex + rescue Gitlab::GitAccess::ForbiddenError => ex error(ex.message, 403) rescue => ex error(ex.message, 500) diff --git a/app/services/lfs/unlock_file_service.rb b/app/services/lfs/unlock_file_service.rb index ea5a67b727f..a13e89904a0 100644 --- a/app/services/lfs/unlock_file_service.rb +++ b/app/services/lfs/unlock_file_service.rb @@ -4,11 +4,11 @@ module Lfs class UnlockFileService < BaseService def execute unless can?(current_user, :push_code, project) - raise Gitlab::GitAccess::UnauthorizedError, _('You have no permissions') + raise Gitlab::GitAccess::ForbiddenError, _('You have no permissions') end unlock_file - rescue Gitlab::GitAccess::UnauthorizedError => ex + rescue Gitlab::GitAccess::ForbiddenError => ex error(ex.message, 403) rescue ActiveRecord::RecordNotFound error(_('Lock not found'), 404) diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb index 38859c1efa4..77fddc44085 100644 --- a/app/services/projects/import_export/export_service.rb +++ b/app/services/projects/import_export/export_service.rb @@ -14,6 +14,8 @@ module Projects save_all! execute_after_export_action(after_export_strategy) + ensure + cleanup end private @@ -24,7 +26,7 @@ module Projects return unless after_export_strategy unless after_export_strategy.execute(current_user, project) - cleanup_and_notify_error + notify_error end end @@ -33,7 +35,7 @@ module Projects Gitlab::ImportExport::Saver.save(exportable: project, shared: shared) notify_success else - cleanup_and_notify_error! + notify_error! end end @@ -54,7 +56,7 @@ module Projects end def project_tree_saver - Gitlab::ImportExport::ProjectTreeSaver.new(project: project, current_user: current_user, shared: shared, params: params) + Gitlab::ImportExport::Project::TreeSaver.new(project: project, current_user: current_user, shared: shared, params: params) end def uploads_saver @@ -73,16 +75,12 @@ module Projects Gitlab::ImportExport::LfsSaver.new(project: project, shared: shared) end - def cleanup_and_notify_error - Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{shared.errors.join(', ')}") # rubocop:disable Gitlab/RailsLogger - - FileUtils.rm_rf(shared.export_path) - - notify_error + def cleanup + FileUtils.rm_rf(shared.archive_path) if shared&.archive_path end - def cleanup_and_notify_error! - cleanup_and_notify_error + def notify_error! + notify_error raise Gitlab::ImportExport::Error.new(shared.errors.to_sentence) end @@ -92,6 +90,8 @@ module Projects end def notify_error + Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{shared.errors.join(', ')}") # rubocop:disable Gitlab/RailsLogger + notification_service.project_not_exported(project, current_user, shared.errors) end end |