Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
10ee137e
未验证
提交
10ee137e
编辑于
10 years ago
作者:
Dmitriy Zaporozhets
浏览文件
操作
下载
补丁
差异文件
Expose timeout and same_ref compare fields
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
上级
24229185
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
4
隐藏空白变更内容
行内
左右并排
显示
4 个更改的文件
doc/api/repositories.md
+17
-30
17 个添加, 30 个删除
doc/api/repositories.md
lib/api/entities.rb
+6
-0
6 个添加, 0 个删除
lib/api/entities.rb
lib/api/repositories.rb
+1
-1
1 个添加, 1 个删除
lib/api/repositories.rb
spec/requests/api/repositories_spec.rb
+3
-0
3 个添加, 0 个删除
spec/requests/api/repositories_spec.rb
有
27 个添加
和
31 个删除
doc/api/repositories.md
+
17
−
30
浏览文件 @
10ee137e
...
...
@@ -152,48 +152,35 @@ GET /projects/:id/repository/compare?from=master&to=feature
Response:
```
json
{
"commit"
:
{
"id"
:
"
72e10ef47e770a95439255b2c49de722e8782106
"
,
"short_id"
:
"
72e10ef47e7
"
,
"title"
:
"
Add NEWFILE
"
,
"id"
:
"
12d65c8dd2b2676fa3ac47d955accc085a37a9c1
"
,
"short_id"
:
"
12d65c8dd2b
"
,
"title"
:
"
JS fix
"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"created_at"
:
"2014-0
5
-2
6
T1
6:03:54
+0
3
:00"
"created_at"
:
"2014-0
2
-2
7
T1
0:27:00
+0
2
:00"
},
"commits"
:
[{
"id"
:
"0b4bc9a49b562e85de7cc9e834518ea6828729b9"
,
"short_id"
:
"0b4bc9a49b5"
,
"title"
:
"Feature added"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"created_at"
:
"2014-02-27T10:26:01+02:00"
},
{
"id"
:
"72e10ef47e770a95439255b2c49de722e8782106"
,
"short_id"
:
"72e10ef47e7"
,
"title"
:
"Add NEWFILE"
,
"id"
:
"12d65c8dd2b2676fa3ac47d955accc085a37a9c1"
,
"short_id"
:
"12d65c8dd2b"
,
"title"
:
"JS fix"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"created_at"
:
"2014-0
5
-2
6
T1
6:03:54
+0
3
:00"
"created_at"
:
"2014-0
2
-2
7
T1
0:27:00
+0
2
:00"
}],
"diffs"
:
[{
"old_path"
:
"
NEWFILE
"
,
"new_path"
:
"
NEWFILE
"
,
"old_path"
:
"
files/js/application.js
"
,
"new_path"
:
"
files/js/application.js
"
,
"a_mode"
:
null
,
"b_mode"
:
null
,
"diff"
:
"---
/dev/null
\n
+++ b/NEWFILE
\n
@@ -0,0 +1 @@
\n
+This is NEWFILE content
\n\\
No newline at end of file
"
,
"new_file"
:
tru
e
,
"b_mode"
:
"100644"
,
"diff"
:
"---
a/files/js/application.js
\n
+++ b/files/js/application.js
\n
@@ -24,8 +24,10 @@
\n
//= require g.raphael-min
\n
//= require g.bar-min
\n
//= require branch-graph
\n
-//= require highlightjs.min
\n
-//= require ace/ace
\n
//= require_tree .
\n
//= require d3
\n
//= require underscore
\n
+
\n
+function fix() {
\n
+ alert(
\"
Fixed
\"
)
\n
+}
"
,
"new_file"
:
fals
e
,
"renamed_file"
:
false
,
"deleted_file"
:
false
},
{
"old_path"
:
"files/ruby/feature.rb"
,
"new_path"
:
"files/ruby/feature.rb"
,
"a_mode"
:
null
,
"b_mode"
:
null
,
"diff"
:
"--- /dev/null
\n
+++ b/files/ruby/feature.rb
\n
@@ -0,0 +1,5 @@
\n
+class Feature
\n
+ def foo
\n
+ puts 'bar'
\n
+ end
\n
+end"
,
"new_file"
:
true
,
"renamed_file"
:
false
,
"deleted_file"
:
false
}]
}],
"compare_timeout"
:
false
,
"compare_same_ref"
:
false
}
```
此差异已折叠。
点击以展开。
lib/api/entities.rb
+
6
−
0
浏览文件 @
10ee137e
...
...
@@ -210,6 +210,12 @@ class Compare < Grape::Entity
expose
:diffs
,
using:
Entities
::
RepoDiff
do
|
compare
,
options
|
compare
.
diffs
end
expose
:compare_timeout
do
|
compare
,
options
|
compare
.
timeout
end
expose
:same
,
as: :compare_same_ref
end
end
end
此差异已折叠。
点击以展开。
lib/api/repositories.rb
+
1
−
1
浏览文件 @
10ee137e
...
...
@@ -130,8 +130,8 @@ def handle_project_member_errors(errors)
# GET /projects/:id/repository/compare?from=master&to=feature
get
':id/repository/compare'
do
authorize!
:download_code
,
user_project
required_attributes!
[
:from
,
:to
]
compare
=
Gitlab
::
Git
::
Compare
.
new
(
user_project
.
repository
.
raw_repository
,
params
[
:from
],
params
[
:to
],
MergeRequestDiff
::
COMMITS_SAFE_SIZE
)
present
compare
,
with:
Entities
::
Compare
end
end
...
...
此差异已折叠。
点击以展开。
spec/requests/api/repositories_spec.rb
+
3
−
0
浏览文件 @
10ee137e
...
...
@@ -118,18 +118,21 @@
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'master'
,
to:
'simple_merge_request'
response
.
status
.
should
==
200
json_response
[
'commits'
].
size
.
should
==
3
json_response
[
'diffs'
].
size
.
should
==
1
end
it
"should compare 2 commits"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'b1e6a9dbf1c85'
,
to:
'1e689bfba395'
response
.
status
.
should
==
200
json_response
[
'commits'
].
size
.
should
==
0
json_response
[
'diffs'
].
size
.
should
==
0
end
it
"should compare 2 commits"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'1e689bfba395'
,
to:
'b1e6a9dbf1c85'
response
.
status
.
should
==
200
json_response
[
'commits'
].
size
.
should
==
4
json_response
[
'diffs'
].
size
.
should
==
9
end
end
end
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录