Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
07e95b0c
Commit
07e95b0c
authored
Jun 18, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose whether current user can push into a branch on branches API
parent
99fdbe4c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
4 deletions
+19
-4
changelogs/unreleased/dm-branch-api-can-push.yml
changelogs/unreleased/dm-branch-api-can-push.yml
+5
-0
doc/api/branches.md
doc/api/branches.md
+8
-3
lib/api/entities.rb
lib/api/entities.rb
+4
-0
spec/fixtures/api/schemas/public_api/v4/branch.json
spec/fixtures/api/schemas/public_api/v4/branch.json
+2
-1
No files found.
changelogs/unreleased/dm-branch-api-can-push.yml
0 → 100644
View file @
07e95b0c
---
title
:
Expose whether current user can push into a branch on branches API
merge_request
:
author
:
type
:
added
doc/api/branches.md
View file @
07e95b0c
...
...
@@ -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
}
```
...
...
lib/api/entities.rb
View file @
07e95b0c
...
...
@@ -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
...
...
spec/fixtures/api/schemas/public_api/v4/branch.json
View file @
07e95b0c
...
...
@@ -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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment