summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorRubén Dávila <rdavila84@gmail.com>2016-02-01 11:26:35 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-02-19 13:14:49 -0500
commitf4ff2ba57b54d54a623140391470de9aece1a75a (patch)
treeb8e105fa40d6cab77edf5390a8373a7b748bccca /app/controllers
parent207522f923063132ba9bb3c95b7404d0eaae3760 (diff)
downloadgitlab-ce-f4ff2ba57b54d54a623140391470de9aece1a75a.tar.gz
Check target branch exists before creating revert MR.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/merge_requests_controller.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 79e6ae26aad..d6bcb852a46 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -10,6 +10,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action :define_show_vars, only: [:show, :diffs, :commits, :builds]
before_action :define_widget_vars, only: [:merge, :cancel_merge_when_build_succeeds, :merge_check]
before_action :ensure_ref_fetched, only: [:show, :diffs, :commits, :builds]
+ before_action :check_target_branch_exists, only: [:revert]
# Allow read any merge_request
before_action :authorize_read_merge_request!
@@ -277,6 +278,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
return render_404 unless @project.merge_requests_enabled
end
+ def check_target_branch_exists
+ return render_404 unless @merge_request.target_branch_exists?
+ end
+
def validates_merge_request
# If source project was removed (Ex. mr from fork to origin)
return invalid_mr unless @merge_request.source_project