Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5d863321
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,发现更多精彩内容 >>
提交
5d863321
编写于
2月 25, 2015
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Send EmailsOnPush when deleting commits using force push.
See #1924.
上级
769f137a
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
30 addition
and
8 deletion
+30
-8
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+5
-1
app/views/notify/repository_push_email.html.haml
app/views/notify/repository_push_email.html.haml
+7
-1
app/views/notify/repository_push_email.text.haml
app/views/notify/repository_push_email.text.haml
+7
-3
app/workers/emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+10
-2
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+1
-1
未找到文件。
app/mailers/emails/projects.rb
浏览文件 @
5d863321
...
@@ -16,9 +16,10 @@ module Emails
...
@@ -16,9 +16,10 @@ module Emails
subject:
subject
(
"Project was moved"
))
subject:
subject
(
"Project was moved"
))
end
end
def
repository_push_email
(
project_id
,
recipient
,
author_id
,
branch
,
compare
,
send_from_committer_email
=
false
,
disable_diffs
=
false
)
def
repository_push_email
(
project_id
,
recipient
,
author_id
,
branch
,
compare
,
reverse_compare
=
false
,
send_from_committer_email
=
false
,
disable_diffs
=
false
)
@project
=
Project
.
find
(
project_id
)
@project
=
Project
.
find
(
project_id
)
@author
=
User
.
find
(
author_id
)
@author
=
User
.
find
(
author_id
)
@reverse_compare
=
reverse_compare
@compare
=
compare
@compare
=
compare
@commits
=
Commit
.
decorate
(
compare
.
commits
)
@commits
=
Commit
.
decorate
(
compare
.
commits
)
@diffs
=
compare
.
diffs
@diffs
=
compare
.
diffs
...
@@ -32,10 +33,13 @@ module Emails
...
@@ -32,10 +33,13 @@ module Emails
@project
,
@project
,
from:
@commits
.
first
,
from:
@commits
.
first
,
to:
@commits
.
last
)
to:
@commits
.
last
)
@subject
<<
"Deleted "
if
@reverse_compare
@subject
<<
"
#{
@commits
.
length
}
commits:
#{
@commits
.
first
.
title
}
"
@subject
<<
"
#{
@commits
.
length
}
commits:
#{
@commits
.
first
.
title
}
"
else
else
@target_url
=
namespace_project_commit_url
(
@project
.
namespace
,
@target_url
=
namespace_project_commit_url
(
@project
.
namespace
,
@project
,
@commits
.
first
)
@project
,
@commits
.
first
)
@subject
<<
"Deleted 1 commit: "
if
@reverse_compare
@subject
<<
@commits
.
first
.
title
@subject
<<
@commits
.
first
.
title
end
end
...
...
app/views/notify/repository_push_email.html.haml
浏览文件 @
5d863321
%h3
#{
@author
.
name
}
pushed to
#{
@branch
}
at
#{
link_to
@project
.
name_with_namespace
,
namespace_project_url
(
@project
.
namespace
,
@project
)
}
%h3
#{
@author
.
name
}
pushed to
#{
@branch
}
at
#{
link_to
@project
.
name_with_namespace
,
namespace_project_url
(
@project
.
namespace
,
@project
)
}
%h4
Commits:
-
if
@reverse_compare
%p
%strong
WARNING:
The push did not contain any new commits, but force pushed to delete the commits and changes below.
%h4
=
@reverse_compare
?
"Deleted commits:"
:
"Commits:"
%ul
%ul
-
@commits
.
each
do
|
commit
|
-
@commits
.
each
do
|
commit
|
...
...
app/views/notify/repository_push_email.text.haml
浏览文件 @
5d863321
#{
@author
.
name
}
pushed to
#{
@branch
}
at
#{
@project
.
name_with_namespace
}
#{
@author
.
name
}
pushed to
#{
@branch
}
at
#{
@project
.
name_with_namespace
}
\
\
Commits:
\
-
if
@reverse_compare
WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.
\
\
=
@reverse_compare
?
"Deleted commits:"
:
"Commits:"
-
@commits
.
each
do
|
commit
|
-
@commits
.
each
do
|
commit
|
#{
commit
.
short_id
}
by
#{
commit
.
author_name
}
#{
commit
.
short_id
}
by
#{
commit
.
author_name
}
at
#{
commit
.
committed_date
.
strftime
(
"%Y-%m-%dT%H:%M:%SZ"
)
}
#{
commit
.
safe_message
}
#{
commit
.
safe_message
}
\- - - - -
\- - - - -
\
\
...
...
app/workers/emails_on_push_worker.rb
浏览文件 @
5d863321
...
@@ -15,8 +15,15 @@ class EmailsOnPushWorker
...
@@ -15,8 +15,15 @@ class EmailsOnPushWorker
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
before_sha
,
after_sha
)
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
before_sha
,
after_sha
)
# Do not send emails if git compare failed
return
false
if
compare
.
same
return
false
unless
compare
&&
compare
.
commits
.
present?
if
compare
.
commits
.
empty?
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
after_sha
,
before_sha
)
reverse_compare
=
true
return
false
if
compare
.
commits
.
empty?
end
recipients
.
split
(
" "
).
each
do
|
recipient
|
recipients
.
split
(
" "
).
each
do
|
recipient
|
Notify
.
repository_push_email
(
Notify
.
repository_push_email
(
...
@@ -25,6 +32,7 @@ class EmailsOnPushWorker
...
@@ -25,6 +32,7 @@ class EmailsOnPushWorker
author_id
,
author_id
,
branch
,
branch
,
compare
,
compare
,
reverse_compare
,
send_from_committer_email
,
send_from_committer_email
,
disable_diffs
disable_diffs
).
deliver
).
deliver
...
...
spec/mailers/notify_spec.rb
浏览文件 @
5d863321
...
@@ -571,7 +571,7 @@ describe Notify do
...
@@ -571,7 +571,7 @@ describe Notify do
let
(
:diff_path
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
commits
.
first
,
to:
commits
.
last
)
}
let
(
:diff_path
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
commits
.
first
,
to:
commits
.
last
)
}
let
(
:send_from_committer_email
)
{
false
}
let
(
:send_from_committer_email
)
{
false
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'master'
,
compare
,
send_from_committer_email
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'master'
,
compare
,
false
,
send_from_committer_email
)
}
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录