Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9479496f
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,体验更适合开发者的 AI 搜索 >>
提交
9479496f
编写于
11月 02, 2015
作者:
V
Valery Sizov
提交者:
Valery Sizov
11月 03, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add added, modified and removed properties to commit object in webhook
上级
b9e53258
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
3 deletion
+42
-3
CHANGELOG
CHANGELOG
+1
-0
doc/web_hooks/web_hooks.md
doc/web_hooks/web_hooks.md
+4
-1
lib/gitlab/push_data_builder.rb
lib/gitlab/push_data_builder.rb
+31
-2
spec/lib/gitlab/push_data_builder_spec.rb
spec/lib/gitlab/push_data_builder_spec.rb
+6
-0
未找到文件。
CHANGELOG
浏览文件 @
9479496f
...
...
@@ -17,6 +17,7 @@ v 8.2.0 (unreleased)
- Remove deprecated CI events from project settings page
- Use issue editor as cross reference comment author when issue is edited with a new mention.
- [API] Add ability to fetch the commit ID of the last commit that actually touched a file
- Add "added", "modified" and "removed" properties to commit object in webhook
v 8.1.1
- Fix cloning Wiki repositories via HTTP (Stan Hu)
...
...
doc/web_hooks/web_hooks.md
浏览文件 @
9479496f
...
...
@@ -69,7 +69,10 @@ X-Gitlab-Event: Push Hook
}
}
],
"total_commits_count"
:
4
"total_commits_count"
:
4
,
"added"
:
[
"CHANGELOG"
],
"modified"
:
[
"app/controller/application.rb"
],
"removed"
:
[]
}
```
...
...
lib/gitlab/push_data_builder.rb
浏览文件 @
9479496f
...
...
@@ -18,7 +18,10 @@ module Gitlab
# homepage: String,
# },
# commits: Array,
# total_commits_count: Fixnum
# total_commits_count: Fixnum,
# added: ["CHANGELOG"],
# modified: [],
# removed: ["tmp/file.txt"]
# }
#
def
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
commits
=
[],
message
=
nil
)
...
...
@@ -33,6 +36,8 @@ module Gitlab
commit_attrs
=
commits_limited
.
map
(
&
:hook_attrs
)
type
=
Gitlab
::
Git
.
tag_ref?
(
ref
)
?
"tag_push"
:
"push"
repo_changes
=
repo_changes
(
project
,
newrev
,
oldrev
)
# Hash to be passed as post_receive_data
data
=
{
object_kind:
type
,
...
...
@@ -55,7 +60,10 @@ module Gitlab
visibility_level:
project
.
visibility_level
},
commits:
commit_attrs
,
total_commits_count:
commits_count
total_commits_count:
commits_count
,
added:
repo_changes
[
:added
],
modified:
repo_changes
[
:modified
],
removed:
repo_changes
[
:removed
]
}
data
...
...
@@ -86,6 +94,27 @@ module Gitlab
newrev
end
end
def
repo_changes
(
project
,
newrev
,
oldrev
)
changes
=
{
added:
[],
modified:
[],
removed:
[]
}
compare_result
=
CompareService
.
new
.
execute
(
project
,
newrev
,
project
,
oldrev
)
if
compare_result
compare_result
.
diffs
.
each
do
|
diff
|
case
true
when
diff
.
deleted_file
changes
[
:removed
]
<<
diff
.
old_path
when
diff
.
renamed_file
,
diff
.
new_file
changes
[
:added
]
<<
diff
.
new_path
else
changes
[
:modified
]
<<
diff
.
new_path
end
end
end
changes
end
end
end
end
spec/lib/gitlab/push_data_builder_spec.rb
浏览文件 @
9479496f
...
...
@@ -17,6 +17,9 @@ describe 'Gitlab::PushDataBuilder' do
it
{
expect
(
data
[
:repository
][
:git_ssh_url
]).
to
eq
(
project
.
ssh_url_to_repo
)
}
it
{
expect
(
data
[
:repository
][
:visibility_level
]).
to
eq
(
project
.
visibility_level
)
}
it
{
expect
(
data
[
:total_commits_count
]).
to
eq
(
3
)
}
it
{
expect
(
data
[
:added
]).
to
eq
([
"gitlab-grack"
])
}
it
{
expect
(
data
[
:modified
]).
to
eq
([
".gitmodules"
,
"files/ruby/popen.rb"
,
"files/ruby/regex.rb"
])
}
it
{
expect
(
data
[
:removed
]).
to
eq
([])
}
end
describe
:build
do
...
...
@@ -35,5 +38,8 @@ describe 'Gitlab::PushDataBuilder' do
it
{
expect
(
data
[
:ref
]).
to
eq
(
'refs/tags/v1.1.0'
)
}
it
{
expect
(
data
[
:commits
]).
to
be_empty
}
it
{
expect
(
data
[
:total_commits_count
]).
to
be_zero
}
it
{
expect
(
data
[
:added
]).
to
eq
([])
}
it
{
expect
(
data
[
:modified
]).
to
eq
([])
}
it
{
expect
(
data
[
:removed
]).
to
eq
([])
}
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录