summaryrefslogtreecommitdiff
path: root/lib/api/merge_requests.rb
diff options
context:
space:
mode:
authorStuart Pook <s.pook@criteo.com>2014-04-04 18:32:53 +0200
committerStuart Pook <s.pook@criteo.com>2014-04-07 16:18:25 +0200
commit66209fbc7668b5b64b34c2997185223891211829 (patch)
tree1d9597aed58c1770bee973c92c90fe8aca56aa8a /lib/api/merge_requests.rb
parent650d0bc695eb0f874561b8d4ed3fc86510573fba (diff)
downloadgitlab-ce-66209fbc7668b5b64b34c2997185223891211829.tar.gz
Add optional parameter to list merge requests
Add an optional parameter to list merge requests to restrict the returned merge requests to those that are "opened", "merged" or "closed". By default all merge requests are returned. Note that "all" can be given to explicitly request all merge requests.
Diffstat (limited to 'lib/api/merge_requests.rb')
-rw-r--r--lib/api/merge_requests.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index e2d2d034444..4b88b0f84c1 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -19,14 +19,24 @@ module API
#
# Parameters:
# id (required) - The ID of a project
+ # state (optional) - Return requests "merged", "opened" or "closed"
#
# Example:
# GET /projects/:id/merge_requests
+ # GET /projects/:id/merge_requests?state=opened
+ # GET /projects/:id/merge_requests?state=closed
#
get ":id/merge_requests" do
authorize! :read_merge_request, user_project
- present paginate(user_project.merge_requests), with: Entities::MergeRequest
+ mrs = case params["state"]
+ when "opened" then user_project.merge_requests.opened
+ when "closed" then user_project.merge_requests.closed
+ when "merged" then user_project.merge_requests.merged
+ else user_project.merge_requests
+ end
+
+ present paginate(mrs), with: Entities::MergeRequest
end
# Show MR