Merge branch 'dm-branch-api-can-push' into 'master'
Expose whether current user can push into a branch on branches API See merge request gitlab-org/gitlab-ce!19958
This commit is contained in:
commit
e7549b9882
4 changed files with 19 additions and 4 deletions
5
changelogs/unreleased/dm-branch-api-can-push.yml
Normal file
5
changelogs/unreleased/dm-branch-api-can-push.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Expose whether current user can push into a branch on branches API
|
||||
merge_request:
|
||||
author:
|
||||
type: added
|
|
@ -29,6 +29,7 @@ Example response:
|
|||
"protected": true,
|
||||
"developers_can_push": false,
|
||||
"developers_can_merge": false,
|
||||
"can_push": true,
|
||||
"commit": {
|
||||
"author_email": "john@example.com",
|
||||
"author_name": "John Smith",
|
||||
|
@ -76,6 +77,7 @@ Example response:
|
|||
"protected": true,
|
||||
"developers_can_push": false,
|
||||
"developers_can_merge": false,
|
||||
"can_push": true,
|
||||
"commit": {
|
||||
"author_email": "john@example.com",
|
||||
"author_name": "John Smith",
|
||||
|
@ -140,7 +142,8 @@ Example response:
|
|||
"merged": false,
|
||||
"protected": true,
|
||||
"developers_can_push": true,
|
||||
"developers_can_merge": true
|
||||
"developers_can_merge": true,
|
||||
"can_push": true
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -188,7 +191,8 @@ Example response:
|
|||
"merged": false,
|
||||
"protected": false,
|
||||
"developers_can_push": false,
|
||||
"developers_can_merge": false
|
||||
"developers_can_merge": false,
|
||||
"can_push": true
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -231,7 +235,8 @@ Example response:
|
|||
"merged": false,
|
||||
"protected": false,
|
||||
"developers_can_push": false,
|
||||
"developers_can_merge": false
|
||||
"developers_can_merge": false,
|
||||
"can_push": true
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -349,6 +349,10 @@ module API
|
|||
expose :developers_can_merge do |repo_branch, options|
|
||||
options[:project].protected_branches.developers_can?(:merge, repo_branch.name)
|
||||
end
|
||||
|
||||
expose :can_push do |repo_branch, options|
|
||||
Gitlab::UserAccess.new(options[:current_user], project: options[:project]).can_push_to_branch?(repo_branch.name)
|
||||
end
|
||||
end
|
||||
|
||||
class TreeObject < Grape::Entity
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
"merged": { "type": "boolean" },
|
||||
"protected": { "type": "boolean" },
|
||||
"developers_can_push": { "type": "boolean" },
|
||||
"developers_can_merge": { "type": "boolean" }
|
||||
"developers_can_merge": { "type": "boolean" },
|
||||
"can_push": { "type": "boolean" }
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue