From 25efc5f288455d4c0920ea5e4dc82e9d845bcb06 Mon Sep 17 00:00:00 2001 From: Riccardo Padovani Date: Sat, 18 Aug 2018 13:00:40 +0200 Subject: [PATCH] Add default parameter to branches API --- .../feature--32877-add-default-field-branch-api.yml | 5 +++++ doc/api/branches.md | 5 +++++ lib/api/entities.rb | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 changelogs/unreleased/feature--32877-add-default-field-branch-api.yml diff --git a/changelogs/unreleased/feature--32877-add-default-field-branch-api.yml b/changelogs/unreleased/feature--32877-add-default-field-branch-api.yml new file mode 100644 index 00000000000..a99ecc9a67e --- /dev/null +++ b/changelogs/unreleased/feature--32877-add-default-field-branch-api.yml @@ -0,0 +1,5 @@ +--- +title: Add default parameter to branches API +merge_request: 21294 +author: Riccardo Padovani +type: changed diff --git a/doc/api/branches.md b/doc/api/branches.md index bfb21608d28..4abf0639eb0 100644 --- a/doc/api/branches.md +++ b/doc/api/branches.md @@ -27,6 +27,7 @@ Example response: "name": "master", "merged": false, "protected": true, + "default": true, "developers_can_push": false, "developers_can_merge": false, "can_push": true, @@ -75,6 +76,7 @@ Example response: "name": "master", "merged": false, "protected": true, + "default": true, "developers_can_push": false, "developers_can_merge": false, "can_push": true, @@ -141,6 +143,7 @@ Example response: "name": "master", "merged": false, "protected": true, + "default": true, "developers_can_push": true, "developers_can_merge": true, "can_push": true @@ -190,6 +193,7 @@ Example response: "name": "master", "merged": false, "protected": false, + "default": true, "developers_can_push": false, "developers_can_merge": false, "can_push": true @@ -234,6 +238,7 @@ Example response: "name": "newbranch", "merged": false, "protected": false, + "default": false, "developers_can_push": false, "developers_can_merge": false, "can_push": true diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 27f28e1df93..3ec63fa7573 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -369,6 +369,10 @@ module API expose :can_push do |repo_branch, options| Gitlab::UserAccess.new(options[:current_user], project: options[:project]).can_push_to_branch?(repo_branch.name) end + + expose :default do |repo_branch, options| + options[:project].default_branch == repo_branch.name + end end class TreeObject < Grape::Entity