diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-19 03:08:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-19 03:08:50 +0300 |
commit | 0171a97525d8578d4f5b5a36f337b1ab947ea317 (patch) | |
tree | 23509c42c3e2404c055899e1c02568008c1ac6d3 /app/services/releases | |
parent | d345547329af023668dcdc691f2a2ae0dffa2626 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/releases')
-rw-r--r-- | app/services/releases/base_service.rb | 6 | ||||
-rw-r--r-- | app/services/releases/create_evidence_service.rb | 2 | ||||
-rw-r--r-- | app/services/releases/update_service.rb | 16 |
3 files changed, 19 insertions, 5 deletions
diff --git a/app/services/releases/base_service.rb b/app/services/releases/base_service.rb index 11004dd2e9f..15d040287a3 100644 --- a/app/services/releases/base_service.rb +++ b/app/services/releases/base_service.rb @@ -63,6 +63,7 @@ module Releases project: project, current_user: current_user, project_ids: Array(project.id), + group_ids: Array(project_group_id), state: 'all', title: params[:milestones] ).execute @@ -79,5 +80,10 @@ module Releases def param_for_milestone_titles_provided? params.key?(:milestones) end + + # overridden in EE + def project_group_id; end end end + +Releases::BaseService.prepend_if_ee('EE::Releases::BaseService') diff --git a/app/services/releases/create_evidence_service.rb b/app/services/releases/create_evidence_service.rb index 9c370722d2c..78b6d77c2cb 100644 --- a/app/services/releases/create_evidence_service.rb +++ b/app/services/releases/create_evidence_service.rb @@ -12,7 +12,7 @@ module Releases summary = ::Evidences::EvidenceSerializer.new.represent(evidence, evidence_options) # rubocop: disable CodeReuse/Serializer evidence.summary = summary - # TODO: fix the sha generating https://gitlab.com/gitlab-org/gitlab/-/issues/209000 + # TODO: fix the sha generation https://gitlab.com/groups/gitlab-org/-/epics/3683 evidence.summary_sha = Gitlab::CryptoHelper.sha256(summary) evidence.save! diff --git a/app/services/releases/update_service.rb b/app/services/releases/update_service.rb index 78d59c76699..4786d35f31e 100644 --- a/app/services/releases/update_service.rb +++ b/app/services/releases/update_service.rb @@ -14,10 +14,18 @@ module Releases params[:milestones] = milestones end - if release.update(params) - success(tag: existing_tag, release: release, milestones_updated: milestones_updated?(previous_milestones)) - else - error(release.errors.messages || '400 Bad request', 400) + # transaction needed as Rails applies `save!` to milestone_releases + # when it does assign_attributes instead of actual saving + # this leads to the validation error being raised + # see https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43385 + ActiveRecord::Base.transaction do + if release.update(params) + success(tag: existing_tag, release: release, milestones_updated: milestones_updated?(previous_milestones)) + else + error(release.errors.messages || '400 Bad request', 400) + end + rescue ActiveRecord::RecordInvalid => e + error(e.message || '400 Bad request', 400) end end |