Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
20bd1e6b
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
20bd1e6b
编写于
9月 05, 2018
作者:
🙈
🙈 jacopo beschi 🙉
提交者:
Douwe Maan
9月 05, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Resolve "Return how many commits the source branch is behind the target branch through the API"
上级
cff47b20
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
2 deletion
+21
-2
changelogs/unreleased/36534-show-commit-behind-mr-api.yml
changelogs/unreleased/36534-show-commit-behind-mr-api.yml
+5
-0
doc/api/merge_requests.md
doc/api/merge_requests.md
+3
-1
lib/api/entities.rb
lib/api/entities.rb
+2
-0
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+2
-1
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+9
-0
未找到文件。
changelogs/unreleased/36534-show-commit-behind-mr-api.yml
0 → 100644
浏览文件 @
20bd1e6b
---
title
:
Adds diverged_commits_count field to GET api/v4/projects/:project_id/merge_requests/:merge_request_iid
merge_request
:
21405
author
:
Jacopo Beschi @jacopo-beschi
type
:
added
doc/api/merge_requests.md
浏览文件 @
20bd1e6b
...
@@ -352,6 +352,7 @@ Parameters:
...
@@ -352,6 +352,7 @@ Parameters:
-
`id`
(required) - The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user
-
`id`
(required) - The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user
-
`merge_request_iid`
(required) - The internal ID of the merge request
-
`merge_request_iid`
(required) - The internal ID of the merge request
-
`render_html`
(optional) - If
`true`
response includes rendered HTML for title and description
-
`render_html`
(optional) - If
`true`
response includes rendered HTML for title and description
-
`include_diverged_commits_count`
(optional) - If
`true`
response includes the commits behind the target branch
```
json
```
json
{
{
...
@@ -435,7 +436,8 @@ Parameters:
...
@@ -435,7 +436,8 @@ Parameters:
"username"
:
"root"
,
"username"
:
"root"
,
"id"
:
1
,
"id"
:
1
,
"name"
:
"Administrator"
"name"
:
"Administrator"
}
},
"diverged_commits_count"
:
2
}
}
```
```
...
...
lib/api/entities.rb
浏览文件 @
20bd1e6b
...
@@ -687,6 +687,8 @@ module API
...
@@ -687,6 +687,8 @@ module API
expose
:diff_refs
,
using:
Entities
::
DiffRefs
expose
:diff_refs
,
using:
Entities
::
DiffRefs
expose
:diverged_commits_count
,
as: :diverged_commits_count
,
if:
->
(
_
,
options
)
{
options
[
:include_diverged_commits_count
]
}
def
build_available?
(
options
)
def
build_available?
(
options
)
options
[
:project
]
&
.
feature_available?
(
:builds
,
options
[
:current_user
])
options
[
:project
]
&
.
feature_available?
(
:builds
,
options
[
:current_user
])
end
end
...
...
lib/api/merge_requests.rb
浏览文件 @
20bd1e6b
...
@@ -233,6 +233,7 @@ module API
...
@@ -233,6 +233,7 @@ module API
params
do
params
do
requires
:merge_request_iid
,
type:
Integer
,
desc:
'The IID of a merge request'
requires
:merge_request_iid
,
type:
Integer
,
desc:
'The IID of a merge request'
optional
:render_html
,
type:
Boolean
,
desc:
'Returns the description and title rendered HTML'
optional
:render_html
,
type:
Boolean
,
desc:
'Returns the description and title rendered HTML'
optional
:include_diverged_commits_count
,
type:
Boolean
,
desc:
'Returns the commits count behind the target branch'
end
end
desc
'Get a single merge request'
do
desc
'Get a single merge request'
do
success
Entities
::
MergeRequest
success
Entities
::
MergeRequest
...
@@ -240,7 +241,7 @@ module API
...
@@ -240,7 +241,7 @@ module API
get
':id/merge_requests/:merge_request_iid'
do
get
':id/merge_requests/:merge_request_iid'
do
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
present
merge_request
,
with:
Entities
::
MergeRequest
,
current_user:
current_user
,
project:
user_project
,
render_html:
params
[
:render_html
]
present
merge_request
,
with:
Entities
::
MergeRequest
,
current_user:
current_user
,
project:
user_project
,
render_html:
params
[
:render_html
]
,
include_diverged_commits_count:
params
[
:include_diverged_commits_count
]
end
end
desc
'Get the participants of a merge request'
do
desc
'Get the participants of a merge request'
do
...
...
spec/requests/api/merge_requests_spec.rb
浏览文件 @
20bd1e6b
...
@@ -353,6 +353,15 @@ describe API::MergeRequests do
...
@@ -353,6 +353,15 @@ describe API::MergeRequests do
end
end
end
end
it
'returns the commits behind the target branch when include_diverged_commits_count is present'
do
allow_any_instance_of
(
merge_request
.
class
).
to
receive
(
:diverged_commits_count
).
and_return
(
1
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
),
include_diverged_commits_count:
true
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'diverged_commits_count'
]).
to
eq
(
1
)
end
it
"returns a 404 error if merge_request_iid not found"
do
it
"returns a 404 error if merge_request_iid not found"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/999"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/999"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录