summaryrefslogtreecommitdiff
path: root/app/services/metrics
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 12:09:47 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 12:09:47 +0000
commit8f9beefac3774b30e911fb00a68f4c7a5244cf27 (patch)
tree919c3a043f8c10bc3f78f3f6e029acfb6b972556 /app/services/metrics
parente4bf776a8829e5186a0f63603c0be627b891d80e (diff)
downloadgitlab-ce-8f9beefac3774b30e911fb00a68f4c7a5244cf27.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/metrics')
-rw-r--r--app/services/metrics/dashboard/update_dashboard_service.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/app/services/metrics/dashboard/update_dashboard_service.rb b/app/services/metrics/dashboard/update_dashboard_service.rb
index 65e6e195f79..25a727ad44c 100644
--- a/app/services/metrics/dashboard/update_dashboard_service.rb
+++ b/app/services/metrics/dashboard/update_dashboard_service.rb
@@ -12,7 +12,8 @@ module Metrics
steps :check_push_authorized,
:check_branch_name,
:check_file_type,
- :update_file
+ :update_file,
+ :create_merge_request
def execute
execute_steps
@@ -49,6 +50,23 @@ module Metrics
end
end
+ def create_merge_request(result)
+ return success(result) if project.default_branch == branch
+
+ merge_request_params = {
+ source_branch: branch,
+ target_branch: project.default_branch,
+ title: params[:commit_message]
+ }
+ merge_request = ::MergeRequests::CreateService.new(project, current_user, merge_request_params).execute
+
+ if merge_request.persisted?
+ success(result.merge(merge_request: Gitlab::UrlBuilder.build(merge_request)))
+ else
+ error(merge_request.errors.full_messages.join(','), :bad_request)
+ end
+ end
+
def push_authorized?
Gitlab::UserAccess.new(current_user, project: project).can_push_to_branch?(branch)
end