Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
ea25fbb8
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 搜索 >>
提交
ea25fbb8
编写于
6月 25, 2018
作者:
M
Mark Chao
提交者:
Sean McGivern
6月 25, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Notify conflict only for opened/locked merge requests
上级
6938335c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
27 deletion
+52
-27
app/models/merge_request.rb
app/models/merge_request.rb
+5
-3
changelogs/unreleased/6598-notify-only-open-unmergeable-mr.yml
...elogs/unreleased/6598-notify-only-open-unmergeable-mr.yml
+5
-0
doc/workflow/notifications.md
doc/workflow/notifications.md
+1
-1
doc/workflow/todos.md
doc/workflow/todos.md
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+40
-22
未找到文件。
app/models/merge_request.rb
浏览文件 @
ea25fbb8
...
...
@@ -129,9 +129,7 @@ class MergeRequest < ActiveRecord::Base
after_transition
unchecked: :cannot_be_merged
do
|
merge_request
,
transition
|
begin
# Merge request can become unmergeable due to many reasons.
# We only notify if it is due to conflict.
unless
merge_request
.
project
.
repository
.
can_be_merged?
(
merge_request
.
diff_head_sha
,
merge_request
.
target_branch
)
if
merge_request
.
notify_conflict?
NotificationService
.
new
.
merge_request_unmergeable
(
merge_request
)
TodoService
.
new
.
merge_request_became_unmergeable
(
merge_request
)
end
...
...
@@ -708,6 +706,10 @@ class MergeRequest < ActiveRecord::Base
should_remove_source_branch?
||
force_remove_source_branch?
end
def
notify_conflict?
(
opened?
||
locked?
)
&&
!
project
.
repository
.
can_be_merged?
(
diff_head_sha
,
target_branch
)
end
def
related_notes
# Fetch comments only from last 100 commits
commits_for_notes_limit
=
100
...
...
changelogs/unreleased/6598-notify-only-open-unmergeable-mr.yml
0 → 100644
浏览文件 @
ea25fbb8
---
title
:
Notify conflict for only open merge request
merge_request
:
20125
author
:
type
:
fixed
doc/workflow/notifications.md
浏览文件 @
ea25fbb8
...
...
@@ -111,7 +111,7 @@ by yourself (except when an issue is due). You will only receive automatic
notifications when somebody else comments or adds changes to the ones that
you've created or mentions you.
If a
merge request becomes unmergeable
, its author will be notified about the cause.
If a
n open merge request becomes unmergeable due to conflict
, its author will be notified about the cause.
If a user has also set the merge request to automatically merge once pipeline succeeds,
then that user will also be notified.
...
...
doc/workflow/todos.md
浏览文件 @
ea25fbb8
...
...
@@ -31,7 +31,7 @@ A Todo appears in your Todos dashboard when:
-
you are
`@mentioned`
in a comment on a commit,
-
a job in the CI pipeline running for your merge request failed, but this
job is not allowed to fail.
-
a
merge request becomes unmergeable
, and you are either:
-
a
n open merge request becomes unmergeable due to conflict
, and you are either:
-
the author, or
-
have set it to automatically merge once pipeline succeeds.
...
...
spec/models/merge_request_spec.rb
浏览文件 @
ea25fbb8
...
...
@@ -2134,8 +2134,7 @@ describe MergeRequest do
describe
'transition to cannot_be_merged'
do
let
(
:notification_service
)
{
double
(
:notification_service
)
}
let
(
:todo_service
)
{
double
(
:todo_service
)
}
subject
{
create
(
:merge_request
,
merge_status: :unchecked
)
}
subject
{
create
(
:merge_request
,
state
,
merge_status: :unchecked
)
}
before
do
allow
(
NotificationService
).
to
receive
(
:new
).
and_return
(
notification_service
)
...
...
@@ -2144,33 +2143,52 @@ describe MergeRequest do
allow
(
subject
.
project
.
repository
).
to
receive
(
:can_be_merged?
).
and_return
(
false
)
end
it
'notifies conflict, but does not notify again if rechecking still results in cannot_be_merged'
do
expect
(
notification_service
).
to
receive
(
:merge_request_unmergeable
).
with
(
subject
).
once
expect
(
todo_service
).
to
receive
(
:merge_request_became_unmergeable
).
with
(
subject
).
once
[
:opened
,
:locked
].
each
do
|
state
|
context
state
do
let
(
:state
)
{
state
}
subject
.
mark_as_unmergeable
subject
.
mark_as_unchecked
subject
.
mark_as_unmergeable
end
it
'notifies conflict, but does not notify again if rechecking still results in cannot_be_merged'
do
expect
(
notification_service
).
to
receive
(
:merge_request_unmergeable
).
with
(
subject
).
once
expect
(
todo_service
).
to
receive
(
:merge_request_became_unmergeable
).
with
(
subject
).
once
subject
.
mark_as_unmergeable
subject
.
mark_as_unchecked
subject
.
mark_as_unmergeable
end
it
'notifies conflict, whenever newly unmergeable'
do
expect
(
notification_service
).
to
receive
(
:merge_request_unmergeable
).
with
(
subject
).
twice
expect
(
todo_service
).
to
receive
(
:merge_request_became_unmergeable
).
with
(
subject
).
twice
subject
.
mark_as_unmergeable
subject
.
mark_as_unchecked
subject
.
mark_as_mergeable
subject
.
mark_as_unchecked
subject
.
mark_as_unmergeable
end
it
'does not notify whenever merge request is newly unmergeable due to other reasons'
do
allow
(
subject
.
project
.
repository
).
to
receive
(
:can_be_merged?
).
and_return
(
true
)
it
'notifies conflict, whenever newly unmergeable'
do
expect
(
notification_service
).
to
receive
(
:merge_request_unmergeable
).
with
(
subject
).
twice
expect
(
todo_service
).
to
receive
(
:merge_request_became_unmergeable
).
with
(
subject
).
twice
expect
(
notification_service
).
not_to
receive
(
:merge_request_unmergeable
)
expect
(
todo_service
).
not_to
receive
(
:merge_request_became_unmergeable
)
subject
.
mark_as_unmergeable
subject
.
mark_as_unchecked
subject
.
mark_as_mergeable
subject
.
mark_as_unchecked
subject
.
mark_as_unmergeable
subject
.
mark_as_unmergeable
end
end
end
it
'does not notify whenever merge request is newly unmergeable due to other reasons'
do
allow
(
subject
.
project
.
repository
).
to
receive
(
:can_be_merged?
).
and_return
(
true
)
[
:closed
,
:merged
].
each
do
|
state
|
let
(
:state
)
{
state
}
expect
(
notification_service
).
not_to
receive
(
:merge_request_unmergeable
)
expect
(
todo_service
).
not_to
receive
(
:merge_request_became_unmergeable
)
context
state
do
it
'does not notify'
do
expect
(
notification_service
).
not_to
receive
(
:merge_request_unmergeable
)
expect
(
todo_service
).
not_to
receive
(
:merge_request_became_unmergeable
)
subject
.
mark_as_unmergeable
subject
.
mark_as_unmergeable
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录