Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
0e355e5c
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 搜索 >>
提交
0e355e5c
编写于
7月 27, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Load and process at most 100 commits when pushing into default branch
上级
4d05e853
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
16 deletion
+29
-16
app/services/git_push_service.rb
app/services/git_push_service.rb
+21
-10
changelogs/unreleased/dm-large-push-performance.yml
changelogs/unreleased/dm-large-push-performance.yml
+4
-0
lib/gitlab/data_builder/push.rb
lib/gitlab/data_builder/push.rb
+2
-2
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+2
-4
未找到文件。
app/services/git_push_service.rb
浏览文件 @
0e355e5c
...
...
@@ -45,6 +45,7 @@ class GitPushService < BaseService
elsif
push_to_existing_branch?
# Collect data for this git push
@push_commits
=
@project
.
repository
.
commits_between
(
params
[
:oldrev
],
params
[
:newrev
])
process_commit_messages
# Update the bare repositories info/attributes file using the contents of the default branches
...
...
@@ -64,15 +65,21 @@ class GitPushService < BaseService
def
update_caches
if
is_default_branch?
paths
=
Set
.
new
if
push_to_new_branch?
# If this is the initial push into the default branch, the file type caches
# will already be reset as a result of `Project#change_head`.
types
=
[]
else
paths
=
Set
.
new
@push_commits
.
each
do
|
commit
|
commit
.
raw_deltas
.
each
do
|
diff
|
paths
<<
diff
.
new_path
@push_commits
.
last
(
PROCESS_COMMIT_LIMIT
).
each
do
|
commit
|
commit
.
raw_deltas
.
each
do
|
diff
|
paths
<<
diff
.
new_path
end
end
end
types
=
Gitlab
::
FileDetector
.
types_in_paths
(
paths
.
to_a
)
types
=
Gitlab
::
FileDetector
.
types_in_paths
(
paths
.
to_a
)
end
else
types
=
[]
end
...
...
@@ -84,7 +91,7 @@ class GitPushService < BaseService
def
process_commit_messages
default
=
is_default_branch?
push_commits
.
last
(
PROCESS_COMMIT_LIMIT
).
each
do
|
commit
|
@
push_commits
.
last
(
PROCESS_COMMIT_LIMIT
).
each
do
|
commit
|
if
commit
.
matches_cross_reference_regex?
ProcessCommitWorker
.
perform_async
(
project
.
id
,
current_user
.
id
,
commit
.
to_hash
,
default
)
...
...
@@ -103,7 +110,7 @@ class GitPushService < BaseService
EventCreateService
.
new
.
push
(
@project
,
current_user
,
build_push_data
)
Ci
::
CreatePipelineService
.
new
(
@project
,
current_user
,
build_push_data
).
execute
(
:push
)
SystemHookPushWorker
.
perform_async
(
build_push_data
.
dup
,
:push_hooks
)
@project
.
execute_hooks
(
build_push_data
.
dup
,
:push_hooks
)
@project
.
execute_services
(
build_push_data
.
dup
,
:push_hooks
)
...
...
@@ -123,7 +130,10 @@ class GitPushService < BaseService
end
def
process_default_branch
@push_commits
=
project
.
repository
.
commits
(
params
[
:newrev
])
@push_commits_count
=
project
.
repository
.
commit_count_for_ref
(
params
[
:ref
])
offset
=
[
@push_commits_count
-
PROCESS_COMMIT_LIMIT
,
0
].
max
@push_commits
=
project
.
repository
.
commits
(
params
[
:newrev
],
offset:
offset
,
limit:
PROCESS_COMMIT_LIMIT
)
# Ensure HEAD points to the default branch in case it is not master
project
.
change_head
(
branch_name
)
...
...
@@ -152,7 +162,8 @@ class GitPushService < BaseService
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
push_commits
)
@push_commits
,
commits_count:
@push_commits_count
)
end
def
push_to_existing_branch?
...
...
changelogs/unreleased/dm-large-push-performance.yml
0 → 100644
浏览文件 @
0e355e5c
---
title
:
Improve performance of large (initial) push into default branch
merge_request
:
author
:
lib/gitlab/data_builder/push.rb
浏览文件 @
0e355e5c
...
...
@@ -24,11 +24,11 @@ module Gitlab
# total_commits_count: Fixnum
# }
#
def
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
commits
=
[],
message
=
nil
)
def
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
commits
=
[],
message
=
nil
,
commits_count:
nil
)
commits
=
Array
(
commits
)
# Total commits count
commits_count
=
commits
.
size
commits_count
||
=
commits
.
size
# Get latest 20 commits ASC
commits_limited
=
commits
.
last
(
20
)
...
...
spec/services/git_push_service_spec.rb
浏览文件 @
0e355e5c
...
...
@@ -663,8 +663,7 @@ describe GitPushService, services: true do
end
it
'only schedules a limited number of commits'
do
allow
(
service
).
to
receive
(
:push_commits
)
.
and_return
(
Array
.
new
(
1000
,
double
(
:commit
,
to_hash:
{},
matches_cross_reference_regex?:
true
)))
service
.
push_commits
=
Array
.
new
(
1000
,
double
(
:commit
,
to_hash:
{},
matches_cross_reference_regex?:
true
))
expect
(
ProcessCommitWorker
).
to
receive
(
:perform_async
).
exactly
(
100
).
times
...
...
@@ -672,8 +671,7 @@ describe GitPushService, services: true do
end
it
"skips commits which don't include cross-references"
do
allow
(
service
).
to
receive
(
:push_commits
)
.
and_return
([
double
(
:commit
,
to_hash:
{},
matches_cross_reference_regex?:
false
)])
service
.
push_commits
=
[
double
(
:commit
,
to_hash:
{},
matches_cross_reference_regex?:
false
)]
expect
(
ProcessCommitWorker
).
not_to
receive
(
:perform_async
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录