Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
94be44c5
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,发现更多精彩内容 >>
提交
94be44c5
编写于
6月 01, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix race condition between pipeline creation and MR diff_head_sha update
上级
42c13b26
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
14 deletion
+9
-14
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+3
-6
app/services/merge_requests/create_service.rb
app/services/merge_requests/create_service.rb
+3
-6
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+3
-2
未找到文件。
app/services/ci/create_pipeline_service.rb
浏览文件 @
94be44c5
...
@@ -63,13 +63,10 @@ module Ci
...
@@ -63,13 +63,10 @@ module Ci
private
private
def
update_merge_requests_head_pipeline
def
update_merge_requests_head_pipeline
merge_requests
=
MergeRequest
.
where
(
source_branch:
@pipeline
.
ref
,
source_project:
@pipeline
.
project
)
return
unless
pipeline
.
latest?
merge_requests
=
merge_requests
.
select
do
|
mr
|
MergeRequest
.
where
(
source_project:
@pipeline
.
project
,
source_branch:
@pipeline
.
ref
).
mr
.
diff_head_sha
==
@pipeline
.
sha
update_all
(
head_pipeline_id:
@pipeline
.
id
)
end
MergeRequest
.
where
(
id:
merge_requests
).
update_all
(
head_pipeline_id:
@pipeline
.
id
)
end
end
def
skip_ci?
def
skip_ci?
...
...
app/services/merge_requests/create_service.rb
浏览文件 @
94be44c5
...
@@ -30,15 +30,12 @@ module MergeRequests
...
@@ -30,15 +30,12 @@ module MergeRequests
def
head_pipeline_for
(
merge_request
)
def
head_pipeline_for
(
merge_request
)
return
unless
merge_request
.
source_project
return
unless
merge_request
.
source_project
sha
=
merge_request
.
source_branch_head
&
.
id
sha
=
merge_request
.
source_branch_sha
return
unless
sha
return
unless
sha
pipelines
=
pipelines
=
merge_request
.
source_project
.
pipelines
.
where
(
ref:
merge_request
.
source_branch
,
sha:
sha
)
Ci
::
Pipeline
.
where
(
ref:
merge_request
.
source_branch
,
project_id:
merge_request
.
source_project
.
id
,
sha:
sha
).
order
(
id: :desc
)
pipelines
.
first
pipelines
.
order
(
id: :desc
).
first
end
end
end
end
end
end
spec/services/ci/create_pipeline_service_spec.rb
浏览文件 @
94be44c5
...
@@ -72,10 +72,11 @@ describe Ci::CreatePipelineService, services: true do
...
@@ -72,10 +72,11 @@ describe Ci::CreatePipelineService, services: true do
end
end
end
end
context
'when
merge request head commit sha does not match pipeline sha
'
do
context
'when
the pipeline is not the latest for the branch
'
do
it
'does not update merge request head pipeline'
do
it
'does not update merge request head pipeline'
do
merge_request
=
create
(
:merge_request
,
source_branch:
'master'
,
target_branch:
"branch_1"
,
source_project:
project
)
merge_request
=
create
(
:merge_request
,
source_branch:
'master'
,
target_branch:
"branch_1"
,
source_project:
project
)
allow_any_instance_of
(
MergeRequestDiff
).
to
receive
(
:head_commit
).
and_return
(
double
(
id:
1234
))
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:latest?
).
and_return
(
false
)
pipeline
pipeline
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录