Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
5d863321
Commit
5d863321
authored
Feb 25, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send EmailsOnPush when deleting commits using force push.
See #1924.
parent
769f137a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
8 deletions
+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
No files found.
app/mailers/emails/projects.rb
View file @
5d863321
...
...
@@ -16,9 +16,10 @@ module Emails
subject:
subject
(
"Project was moved"
))
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
)
@author
=
User
.
find
(
author_id
)
@reverse_compare
=
reverse_compare
@compare
=
compare
@commits
=
Commit
.
decorate
(
compare
.
commits
)
@diffs
=
compare
.
diffs
...
...
@@ -32,10 +33,13 @@ module Emails
@project
,
from:
@commits
.
first
,
to:
@commits
.
last
)
@subject
<<
"Deleted "
if
@reverse_compare
@subject
<<
"
#{
@commits
.
length
}
commits:
#{
@commits
.
first
.
title
}
"
else
@target_url
=
namespace_project_commit_url
(
@project
.
namespace
,
@project
,
@commits
.
first
)
@subject
<<
"Deleted 1 commit: "
if
@reverse_compare
@subject
<<
@commits
.
first
.
title
end
...
...
app/views/notify/repository_push_email.html.haml
View file @
5d863321
%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
-
@commits
.
each
do
|
commit
|
...
...
app/views/notify/repository_push_email.text.haml
View file @
5d863321
#{
@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
|
#{
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
}
\- - - - -
\
...
...
app/workers/emails_on_push_worker.rb
View file @
5d863321
...
...
@@ -15,8 +15,15 @@ class EmailsOnPushWorker
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
before_sha
,
after_sha
)
# Do not send emails if git compare failed
return
false
unless
compare
&&
compare
.
commits
.
present?
return
false
if
compare
.
same
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
|
Notify
.
repository_push_email
(
...
...
@@ -25,6 +32,7 @@ class EmailsOnPushWorker
author_id
,
branch
,
compare
,
reverse_compare
,
send_from_committer_email
,
disable_diffs
).
deliver
...
...
spec/mailers/notify_spec.rb
View file @
5d863321
...
...
@@ -571,7 +571,7 @@ describe Notify do
let
(
:diff_path
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
commits
.
first
,
to:
commits
.
last
)
}
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
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment