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
2ce66c07
Commit
2ce66c07
authored
Nov 28, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Expose branch status
parent
060ec3d7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
1 deletion
+25
-1
changelogs/unreleased/api-branch-status.yml
changelogs/unreleased/api-branch-status.yml
+4
-0
doc/api/branches.md
doc/api/branches.md
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+5
-1
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+11
-0
No files found.
changelogs/unreleased/api-branch-status.yml
0 → 100644
View file @
2ce66c07
---
title
:
'
API:
Expose
merge
status
for
branch
API'
merge_request
:
author
:
Robert Schilling
doc/api/branches.md
View file @
2ce66c07
...
@@ -22,6 +22,7 @@ Example response:
...
@@ -22,6 +22,7 @@ Example response:
[
[
{
{
"name"
:
"master"
,
"name"
:
"master"
,
"merged"
:
false
,
"protected"
:
true
,
"protected"
:
true
,
"developers_can_push"
:
false
,
"developers_can_push"
:
false
,
"developers_can_merge"
:
false
,
"developers_can_merge"
:
false
,
...
@@ -65,6 +66,7 @@ Example response:
...
@@ -65,6 +66,7 @@ Example response:
```
json
```
json
{
{
"name"
:
"master"
,
"name"
:
"master"
,
"merged"
:
false
,
"protected"
:
true
,
"protected"
:
true
,
"developers_can_push"
:
false
,
"developers_can_push"
:
false
,
"developers_can_merge"
:
false
,
"developers_can_merge"
:
false
,
...
@@ -123,6 +125,7 @@ Example response:
...
@@ -123,6 +125,7 @@ Example response:
]
]
},
},
"name"
:
"master"
,
"name"
:
"master"
,
"merged"
:
false
,
"protected"
:
true
,
"protected"
:
true
,
"developers_can_push"
:
true
,
"developers_can_push"
:
true
,
"developers_can_merge"
:
true
"developers_can_merge"
:
true
...
@@ -166,6 +169,7 @@ Example response:
...
@@ -166,6 +169,7 @@ Example response:
]
]
},
},
"name"
:
"master"
,
"name"
:
"master"
,
"merged"
:
false
,
"protected"
:
false
,
"protected"
:
false
,
"developers_can_push"
:
false
,
"developers_can_push"
:
false
,
"developers_can_merge"
:
false
"developers_can_merge"
:
false
...
@@ -206,6 +210,7 @@ Example response:
...
@@ -206,6 +210,7 @@ Example response:
]
]
},
},
"name"
:
"newbranch"
,
"name"
:
"newbranch"
,
"merged"
:
false
,
"protected"
:
false
,
"protected"
:
false
,
"developers_can_push"
:
false
,
"developers_can_push"
:
false
,
"developers_can_merge"
:
false
"developers_can_merge"
:
false
...
...
lib/api/entities.rb
View file @
2ce66c07
...
@@ -141,8 +141,12 @@ module API
...
@@ -141,8 +141,12 @@ module API
options
[
:project
].
repository
.
commit
(
repo_branch
.
dereferenced_target
)
options
[
:project
].
repository
.
commit
(
repo_branch
.
dereferenced_target
)
end
end
expose
:merged
do
|
repo_branch
,
options
|
options
[
:project
].
repository
.
merged_to_root_ref?
(
repo_branch
.
name
)
end
expose
:protected
do
|
repo_branch
,
options
|
expose
:protected
do
|
repo_branch
,
options
|
options
[
:project
].
protected_branch?
repo_branch
.
name
options
[
:project
].
protected_branch?
(
repo_branch
.
name
)
end
end
expose
:developers_can_push
do
|
repo_branch
,
options
|
expose
:developers_can_push
do
|
repo_branch
,
options
|
...
...
spec/requests/api/branches_spec.rb
View file @
2ce66c07
...
@@ -31,11 +31,22 @@ describe API::API, api: true do
...
@@ -31,11 +31,22 @@ describe API::API, api: true do
expect
(
json_response
[
'name'
]).
to
eq
(
branch_name
)
expect
(
json_response
[
'name'
]).
to
eq
(
branch_name
)
expect
(
json_response
[
'commit'
][
'id'
]).
to
eq
(
branch_sha
)
expect
(
json_response
[
'commit'
][
'id'
]).
to
eq
(
branch_sha
)
expect
(
json_response
[
'merged'
]).
to
eq
(
false
)
expect
(
json_response
[
'protected'
]).
to
eq
(
false
)
expect
(
json_response
[
'protected'
]).
to
eq
(
false
)
expect
(
json_response
[
'developers_can_push'
]).
to
eq
(
false
)
expect
(
json_response
[
'developers_can_push'
]).
to
eq
(
false
)
expect
(
json_response
[
'developers_can_merge'
]).
to
eq
(
false
)
expect
(
json_response
[
'developers_can_merge'
]).
to
eq
(
false
)
end
end
context
'on a merged branch'
do
it
"returns the branch information for a single branch"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches/merge-test"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'name'
]).
to
eq
(
'merge-test'
)
expect
(
json_response
[
'merged'
]).
to
eq
(
true
)
end
end
it
"returns a 403 error if guest"
do
it
"returns a 403 error if guest"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user2
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user2
)
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_http_status
(
403
)
...
...
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