summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorHiroyuki Sato <sathiroyuki@gmail.com>2018-01-12 20:38:36 +0000
committerClement Ho <clemmakesapps@gmail.com>2018-01-12 20:38:36 +0000
commita7d26f00c35b945199d40332349f463043ae6122 (patch)
tree7b76a2e305e4a4f81f61271337c9731d0d50e16f /app/controllers
parent1b5f179557d03683f92ed3af3d357df056cc8ece (diff)
downloadgitlab-ce-a7d26f00c35b945199d40332349f463043ae6122.tar.gz
Display related merge requests in commit detail page
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/commit_controller.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 2e7344b1cad..effb484ef0f 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -12,7 +12,7 @@ class Projects::CommitController < Projects::ApplicationController
before_action :authorize_download_code!
before_action :authorize_read_pipeline!, only: [:pipelines]
before_action :commit
- before_action :define_commit_vars, only: [:show, :diff_for_path, :pipelines]
+ before_action :define_commit_vars, only: [:show, :diff_for_path, :pipelines, :merge_requests]
before_action :define_note_vars, only: [:show, :diff_for_path]
before_action :authorize_edit_tree!, only: [:revert, :cherry_pick]
@@ -52,6 +52,18 @@ class Projects::CommitController < Projects::ApplicationController
end
end
+ def merge_requests
+ @merge_requests = @commit.merge_requests.map do |mr|
+ { iid: mr.iid, path: merge_request_path(mr), title: mr.title }
+ end
+
+ respond_to do |format|
+ format.json do
+ render json: @merge_requests.to_json
+ end
+ end
+ end
+
def branches
# branch_names_contains/tag_names_contains can take a long time when there are thousands of
# branches/tags - each `git branch --contains xxx` request can consume a cpu core.