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
Kazuhiko Shiozaki
gitlab-ce
Commits
85af3e82
Commit
85af3e82
authored
Feb 25, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to disable code diffs to EmailOnPush.
See #1950
parent
e0c186c3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
42 deletions
+60
-42
app/controllers/admin/services_controller.rb
app/controllers/admin/services_controller.rb
+1
-1
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+1
-1
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+2
-1
app/models/project_services/emails_on_push_service.rb
app/models/project_services/emails_on_push_service.rb
+7
-1
app/views/notify/repository_push_email.html.haml
app/views/notify/repository_push_email.html.haml
+23
-22
app/views/notify/repository_push_email.text.haml
app/views/notify/repository_push_email.text.haml
+16
-14
app/workers/emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+10
-2
No files found.
app/controllers/admin/services_controller.rb
View file @
85af3e82
...
@@ -46,7 +46,7 @@ class Admin::ServicesController < Admin::ApplicationController
...
@@ -46,7 +46,7 @@ class Admin::ServicesController < Admin::ApplicationController
:user_key
,
:device
,
:priority
,
:sound
,
:bamboo_url
,
:username
,
:password
,
:user_key
,
:device
,
:priority
,
:sound
,
:bamboo_url
,
:username
,
:password
,
:build_key
,
:server
,
:teamcity_url
,
:build_type
,
:build_key
,
:server
,
:teamcity_url
,
:build_type
,
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:send_from_committer_email
:send_from_committer_email
,
:disable_diffs
])
])
end
end
end
end
app/controllers/projects/services_controller.rb
View file @
85af3e82
...
@@ -51,7 +51,7 @@ class Projects::ServicesController < Projects::ApplicationController
...
@@ -51,7 +51,7 @@ class Projects::ServicesController < Projects::ApplicationController
:user_key
,
:device
,
:priority
,
:sound
,
:bamboo_url
,
:username
,
:password
,
:user_key
,
:device
,
:priority
,
:sound
,
:bamboo_url
,
:username
,
:password
,
:build_key
,
:server
,
:teamcity_url
,
:build_type
,
:build_key
,
:server
,
:teamcity_url
,
:build_type
,
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:send_from_committer_email
:send_from_committer_email
,
:disable_diffs
)
)
end
end
end
end
app/mailers/emails/projects.rb
View file @
85af3e82
...
@@ -16,13 +16,14 @@ module Emails
...
@@ -16,13 +16,14 @@ 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
)
def
repository_push_email
(
project_id
,
recipient
,
author_id
,
branch
,
compare
,
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
)
@compare
=
compare
@compare
=
compare
@commits
=
Commit
.
decorate
(
compare
.
commits
)
@commits
=
Commit
.
decorate
(
compare
.
commits
)
@diffs
=
compare
.
diffs
@diffs
=
compare
.
diffs
@branch
=
branch
.
gsub
(
"refs/heads/"
,
""
)
@branch
=
branch
.
gsub
(
"refs/heads/"
,
""
)
@disable_diffs
=
disable_diffs
@subject
=
"[
#{
@project
.
path_with_namespace
}
][
#{
@branch
}
] "
@subject
=
"[
#{
@project
.
path_with_namespace
}
][
#{
@branch
}
] "
...
...
app/models/project_services/emails_on_push_service.rb
View file @
85af3e82
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
class
EmailsOnPushService
<
Service
class
EmailsOnPushService
<
Service
prop_accessor
:send_from_committer_email
prop_accessor
:send_from_committer_email
prop_accessor
:disable_diffs
prop_accessor
:recipients
prop_accessor
:recipients
validates
:recipients
,
presence:
true
,
if: :activated?
validates
:recipients
,
presence:
true
,
if: :activated?
...
@@ -34,13 +35,18 @@ class EmailsOnPushService < Service
...
@@ -34,13 +35,18 @@ class EmailsOnPushService < Service
self
.
send_from_committer_email
==
"1"
self
.
send_from_committer_email
==
"1"
end
end
def
disable_diffs?
self
.
disable_diffs
==
"1"
end
def
execute
(
push_data
)
def
execute
(
push_data
)
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
push_data
,
se
lf
.
send_from_committer_email
?
)
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
push_data
,
se
nd_from_committer_email?
,
disable_diffs
?
)
end
end
def
fields
def
fields
[
[
{
type:
'checkbox'
,
name:
'send_from_committer_email'
,
title:
"Send from committer email if domain matches"
},
{
type:
'checkbox'
,
name:
'send_from_committer_email'
,
title:
"Send from committer email if domain matches"
},
{
type:
'checkbox'
,
name:
'disable_diffs'
,
title:
"Disable code diffs"
},
{
type:
'textarea'
,
name:
'recipients'
,
placeholder:
'Emails separated by whitespace'
},
{
type:
'textarea'
,
name:
'recipients'
,
placeholder:
'Emails separated by whitespace'
},
]
]
end
end
...
...
app/views/notify/repository_push_email.html.haml
View file @
85af3e82
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
%ul
%ul
-
@diffs
.
each_with_index
do
|
diff
,
i
|
-
@diffs
.
each_with_index
do
|
diff
,
i
|
%li
.file-stats
%li
.file-stats
%a
{
href:
"#
diff-#{i}"
}
%a
{
href:
"#
{@target_url if @disable_diffs}#diff-#{i}"
}
-
if
diff
.
deleted_file
-
if
diff
.
deleted_file
%span
.deleted-file
%span
.deleted-file
−
−
...
@@ -32,27 +32,28 @@
...
@@ -32,27 +32,28 @@
-
else
-
else
=
diff
.
new_path
=
diff
.
new_path
%h4
Changes:
-
unless
@disable_diffs
-
@diffs
.
each_with_index
do
|
diff
,
i
|
%h4
Changes:
%li
{
id:
"diff-#{i}"
}
-
@diffs
.
each_with_index
do
|
diff
,
i
|
%a
{
href:
@target_url
+
"#diff-#{i}"
}
%li
{
id:
"diff-#{i}"
}
-
if
diff
.
deleted_file
%a
{
href:
@target_url
+
"#diff-#{i}"
}
%strong
-
if
diff
.
deleted_file
=
diff
.
old_path
%strong
deleted
=
diff
.
old_path
-
elsif
diff
.
renamed_file
deleted
%strong
-
elsif
diff
.
renamed_file
=
diff
.
old_path
%strong
→
=
diff
.
old_path
%strong
→
=
diff
.
new_path
%strong
-
else
=
diff
.
new_path
%strong
-
else
=
diff
.
new_path
%strong
%hr
=
diff
.
new_path
%pre
%hr
=
color_email_diff
(
diff
.
diff
)
%pre
%br
=
color_email_diff
(
diff
.
diff
)
%br
-
if
@compare
.
timeout
-
if
@compare
.
timeout
%h5
Huge diff. To prevent performance issues changes are hidden
%h5
Huge diff. To prevent performance issues changes are hidden
app/views/notify/repository_push_email.text.haml
View file @
85af3e82
...
@@ -19,20 +19,22 @@ Commits:
...
@@ -19,20 +19,22 @@ Commits:
\- +
#{
diff
.
new_path
}
\- +
#{
diff
.
new_path
}
-
else
-
else
\-
#{
diff
.
new_path
}
\-
#{
diff
.
new_path
}
\
-
unless
@disable_diffs
\
Changes:
-
@diffs
.
each
do
|
diff
|
\
\
\=====================================
\
-
if
diff
.
deleted_file
Changes:
#{
diff
.
old_path
}
deleted
-
@diffs
.
each
do
|
diff
|
-
elsif
diff
.
renamed_file
\
#{
diff
.
old_path
}
→
#{
diff
.
new_path
}
\=====================================
-
else
-
if
diff
.
deleted_file
=
diff
.
new_path
#{
diff
.
old_path
}
deleted
\=====================================
-
elsif
diff
.
renamed_file
!=
diff
.
diff
#{
diff
.
old_path
}
→
#{
diff
.
new_path
}
\
-
else
=
diff
.
new_path
\=====================================
!=
diff
.
diff
-
if
@compare
.
timeout
-
if
@compare
.
timeout
\
\
Huge diff. To prevent performance issues it was hidden
Huge diff. To prevent performance issues it was hidden
app/workers/emails_on_push_worker.rb
View file @
85af3e82
class
EmailsOnPushWorker
class
EmailsOnPushWorker
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
def
perform
(
project_id
,
recipients
,
push_data
,
send_from_committer_email
=
false
)
def
perform
(
project_id
,
recipients
,
push_data
,
send_from_committer_email
=
false
,
disable_diffs
=
false
)
project
=
Project
.
find
(
project_id
)
project
=
Project
.
find
(
project_id
)
before_sha
=
push_data
[
"before"
]
before_sha
=
push_data
[
"before"
]
after_sha
=
push_data
[
"after"
]
after_sha
=
push_data
[
"after"
]
...
@@ -19,7 +19,15 @@ class EmailsOnPushWorker
...
@@ -19,7 +19,15 @@ class EmailsOnPushWorker
return
false
unless
compare
&&
compare
.
commits
.
present?
return
false
unless
compare
&&
compare
.
commits
.
present?
recipients
.
split
(
" "
).
each
do
|
recipient
|
recipients
.
split
(
" "
).
each
do
|
recipient
|
Notify
.
repository_push_email
(
project_id
,
recipient
,
author_id
,
branch
,
compare
,
send_from_committer_email
).
deliver
Notify
.
repository_push_email
(
project_id
,
recipient
,
author_id
,
branch
,
compare
,
send_from_committer_email
,
disable_diffs
).
deliver
end
end
ensure
ensure
compare
=
nil
compare
=
nil
...
...
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