Add default parameter to branches API

This commit is contained in:
Riccardo Padovani 2018-08-18 13:00:40 +02:00
parent 197a305b84
commit 25efc5f288
3 changed files with 14 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
title: Add default parameter to branches API
merge_request: 21294
author: Riccardo Padovani
type: changed

View file

@ -27,6 +27,7 @@ Example response:
"name": "master", "name": "master",
"merged": false, "merged": false,
"protected": true, "protected": true,
"default": true,
"developers_can_push": false, "developers_can_push": false,
"developers_can_merge": false, "developers_can_merge": false,
"can_push": true, "can_push": true,
@ -75,6 +76,7 @@ Example response:
"name": "master", "name": "master",
"merged": false, "merged": false,
"protected": true, "protected": true,
"default": true,
"developers_can_push": false, "developers_can_push": false,
"developers_can_merge": false, "developers_can_merge": false,
"can_push": true, "can_push": true,
@ -141,6 +143,7 @@ Example response:
"name": "master", "name": "master",
"merged": false, "merged": false,
"protected": true, "protected": true,
"default": true,
"developers_can_push": true, "developers_can_push": true,
"developers_can_merge": true, "developers_can_merge": true,
"can_push": true "can_push": true
@ -190,6 +193,7 @@ Example response:
"name": "master", "name": "master",
"merged": false, "merged": false,
"protected": false, "protected": false,
"default": true,
"developers_can_push": false, "developers_can_push": false,
"developers_can_merge": false, "developers_can_merge": false,
"can_push": true "can_push": true
@ -234,6 +238,7 @@ Example response:
"name": "newbranch", "name": "newbranch",
"merged": false, "merged": false,
"protected": false, "protected": false,
"default": false,
"developers_can_push": false, "developers_can_push": false,
"developers_can_merge": false, "developers_can_merge": false,
"can_push": true "can_push": true

View file

@ -369,6 +369,10 @@ module API
expose :can_push do |repo_branch, options| expose :can_push do |repo_branch, options|
Gitlab::UserAccess.new(options[:current_user], project: options[:project]).can_push_to_branch?(repo_branch.name) Gitlab::UserAccess.new(options[:current_user], project: options[:project]).can_push_to_branch?(repo_branch.name)
end end
expose :default do |repo_branch, options|
options[:project].default_branch == repo_branch.name
end
end end
class TreeObject < Grape::Entity class TreeObject < Grape::Entity