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
Jérome Perrin
gitlab-ce
Commits
9f2752e5
Commit
9f2752e5
authored
Nov 21, 2015
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove obsolete variables in `repository_push_email`
parent
4beba749
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
48 deletions
+46
-48
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+5
-20
app/views/notify/repository_push_email.html.haml
app/views/notify/repository_push_email.html.haml
+15
-13
app/views/notify/repository_push_email.text.haml
app/views/notify/repository_push_email.text.haml
+12
-12
lib/gitlab/email/message/repository_push.rb
lib/gitlab/email/message/repository_push.rb
+14
-3
No files found.
app/mailers/emails/projects.rb
View file @
9f2752e5
...
...
@@ -60,28 +60,13 @@ module Emails
end
def
repository_push_email
(
project_id
,
recipient
,
opts
=
{})
repository_push
=
@message
=
Gitlab
::
Email
::
Message
::
RepositoryPush
.
new
(
self
,
project_id
,
recipient
,
opts
)
@project
=
repository_push
.
project
@current_user
=
@author
=
repository_push
.
author
@compare
=
repository_push
.
compare
@ref_name
=
repository_push
.
ref_name
@ref_type
=
repository_push
.
ref_type
@action
=
repository_push
.
action
@action_name
=
repository_push
.
action_name
@commits
=
repository_push
.
commits
@diffs
=
repository_push
.
diffs
@target_url
=
repository_push
.
target_url
@disable_diffs
=
repository_push
.
disable_diffs?
@reverse_compare
=
repository_push
.
reverse_compare?
@disable_footer
=
true
mail
(
from:
sender
(
repository_push
.
author_id
,
repository_push
.
send_from_committer_email?
),
reply_to:
repository_push
.
reply_to
,
to:
repository_push
.
recipient
,
subject:
repository_push
.
subject
)
mail
(
from:
sender
(
@message
.
author_id
,
@message
.
send_from_committer_email?
),
reply_to:
@message
.
reply_to
,
to:
@message
.
recipient
,
subject:
@message
.
subject
)
end
end
end
app/views/notify/repository_push_email.html.haml
View file @
9f2752e5
%h3
#{
@author
.
name
}
#{
@action_name
}
#{
@ref_type
}
#{
@ref_name
}
at
#{
link_to
@project
.
name_with_namespace
,
namespace_project_url
(
@project
.
namespace
,
@project
)
}
%h3
#{
@message
.
author_name
}
#{
@message
.
action_name
}
#{
@message
.
ref_type
}
#{
@message
.
ref_name
}
at
#{
link_to
(
@message
.
project_name_with_namespace
,
namespace_project_url
(
@message
.
project_namespace
,
@message
.
project
))
}
-
if
@compare
-
if
@
reverse_compare
-
if
@
message
.
compare
-
if
@
message
.
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:"
=
@
message
.
reverse_compare?
?
"Deleted commits:"
:
"Commits:"
%ul
-
@commits
.
each
do
|
commit
|
-
@
message
.
commits
.
each
do
|
commit
|
%li
%strong
#{
link_to
commit
.
short_id
,
namespace_project_commit_url
(
@project
.
namespace
,
@project
,
commit
)
}
%strong
#{
link_to
(
commit
.
short_id
,
namespace_project_commit_url
(
@message
.
project_namespace
,
@message
.
project
,
commit
)
)
}
%div
%span
by
#{
commit
.
author_name
}
%i
at
#{
commit
.
committed_date
.
strftime
(
"%Y-%m-%dT%H:%M:%SZ"
)
}
%pre
.commit-message
=
commit
.
safe_message
%h4
#{
pluralize
@
diffs
.
count
,
"changed file"
}
:
%h4
#{
pluralize
@
message
.
diffs_
count
,
"changed file"
}
:
%ul
-
@diffs
.
each_with_index
do
|
diff
,
i
|
-
@
message
.
diffs
.
each_with_index
do
|
diff
,
i
|
%li
.file-stats
%a
{
href:
"#{@
target_url if @disable_diffs
}#diff-#{i}"
}
%a
{
href:
"#{@
message.target_url if @message.disable_diffs?
}#diff-#{i}"
}
-
if
diff
.
deleted_file
%span
.deleted-file
−
...
...
@@ -40,11 +42,11 @@
-
else
=
diff
.
new_path
-
unless
@
disable_diffs
-
unless
@
message
.
disable_diffs?
%h4
Changes:
-
@diffs
.
each_with_index
do
|
diff
,
i
|
-
@
message
.
diffs
.
each_with_index
do
|
diff
,
i
|
%li
{
id:
"diff-#{i}"
}
%a
{
href:
@target_url
+
"#diff-#{i}"
}
%a
{
href:
@
message
.
target_url
+
"#diff-#{i}"
}
-
if
diff
.
deleted_file
%strong
=
diff
.
old_path
...
...
@@ -62,5 +64,5 @@
=
color_email_diff
(
diff
.
diff
)
%br
-
if
@
compare
.
timeout
-
if
@
message
.
compare_
timeout
%h5
Huge diff. To prevent performance issues changes are hidden
app/views/notify/repository_push_email.text.haml
View file @
9f2752e5
#{
@
author
.
name
}
#{
@action_name
}
#{
@ref_type
}
#{
@ref_name
}
at
#{
@project
.
name_with_namespace
}
-
if
@compare
#{
@
message
.
author_name
}
#{
@message
.
action_name
}
#{
@message
.
ref_type
}
#{
@message
.
ref_name
}
at
#{
@message
.
project_
name_with_namespace
}
-
if
@
message
.
compare
\
\
-
if
@
reverse_compare
-
if
@
message
.
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
|
=
@
message
.
reverse_compare?
?
"Deleted commits:"
:
"Commits:"
-
@
message
.
commits
.
each
do
|
commit
|
#{
commit
.
short_id
}
by
#{
commit
.
author_name
}
at
#{
commit
.
committed_date
.
strftime
(
"%Y-%m-%dT%H:%M:%SZ"
)
}
#{
commit
.
safe_message
}
\- - - - -
\
\
#{
pluralize
@
diffs
.
count
,
"changed file"
}
:
#{
pluralize
@
message
.
diffs_
count
,
"changed file"
}
:
\
-
@diffs
.
each
do
|
diff
|
-
@
message
.
diffs
.
each
do
|
diff
|
-
if
diff
.
deleted_file
\- −
#{
diff
.
old_path
}
-
elsif
diff
.
renamed_file
...
...
@@ -24,11 +24,11 @@
\- +
#{
diff
.
new_path
}
-
else
\-
#{
diff
.
new_path
}
-
unless
@
disable_diffs
-
unless
@
message
.
disable_diffs?
\
\
Changes:
-
@diffs
.
each
do
|
diff
|
-
@
message
.
diffs
.
each
do
|
diff
|
\
\=====================================
-
if
diff
.
deleted_file
...
...
@@ -39,11 +39,11 @@
=
diff
.
new_path
\=====================================
!=
diff
.
diff
-
if
@
compare
.
timeout
-
if
@
message
.
compare_
timeout
\
\
Huge diff. To prevent performance issues it was hidden
-
if
@target_url
-
if
@
message
.
target_url
\
\
View it on GitLab:
#{
@target_url
}
View it on GitLab:
#{
@
message
.
target_url
}
lib/gitlab/email/message/repository_push.rb
View file @
9f2752e5
...
...
@@ -5,6 +5,9 @@ module Gitlab
attr_accessor
:recipient
attr_reader
:author_id
,
:ref
,
:action
delegate
:namespace
,
:name_with_namespace
,
to: :project
,
prefix: :project
delegate
:name
,
to: :author
,
prefix: :author
def
initialize
(
notify
,
project_id
,
recipient
,
opts
=
{})
raise
ArgumentError
,
'Missing options: author_id, ref, action'
unless
opts
[
:author_id
]
&&
opts
[
:ref
]
&&
opts
[
:action
]
...
...
@@ -35,10 +38,18 @@ module Gitlab
@diffs
||=
(
compare
.
diffs
if
compare
)
end
def
diffs_count
diffs
.
count
if
diffs
end
def
compare
@opts
[
:compare
]
end
def
compare_timeout
compare
.
timeout
if
compare
end
def
reverse_compare?
@opts
[
:reverse_compare
]
||
false
end
...
...
@@ -74,17 +85,17 @@ module Gitlab
def
target_url
if
@action
==
:push
if
commits
.
length
>
1
&&
compare
@notify
.
namespace_project_compare_url
(
project
.
namespace
,
@notify
.
namespace_project_compare_url
(
project
_
namespace
,
project
,
from:
Commit
.
new
(
compare
.
base
,
project
),
to:
Commit
.
new
(
compare
.
head
,
project
))
else
@notify
.
namespace_project_commit_url
(
project
.
namespace
,
@notify
.
namespace_project_commit_url
(
project
_
namespace
,
project
,
commits
.
first
)
end
else
unless
@action
==
:delete
@notify
.
namespace_project_tree_url
(
project
.
namespace
,
@notify
.
namespace_project_tree_url
(
project
_
namespace
,
project
,
ref_name
)
end
end
...
...
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