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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
6ac73f45
Commit
6ac73f45
authored
Dec 18, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move EmailOnPush logic to async worker
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
fc3878c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
19 deletions
+26
-19
app/models/project_services/emails_on_push_service.rb
app/models/project_services/emails_on_push_service.rb
+1
-19
app/workers/emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+25
-0
No files found.
app/models/project_services/emails_on_push_service.rb
View file @
6ac73f45
...
@@ -33,24 +33,7 @@ class EmailsOnPushService < Service
...
@@ -33,24 +33,7 @@ class EmailsOnPushService < Service
end
end
def
execute
(
push_data
)
def
execute
(
push_data
)
before_sha
=
push_data
[
:before
]
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
push_data
)
after_sha
=
push_data
[
:after
]
branch
=
push_data
[
:ref
]
author_id
=
push_data
[
:user_id
]
if
before_sha
=~
/^000000/
||
after_sha
=~
/^000000/
# skip if new branch was pushed or branch was removed
return
true
end
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?
recipients
.
split
(
" "
).
each
do
|
recipient
|
Notify
.
delay
.
repository_push_email
(
project_id
,
recipient
,
author_id
,
branch
,
compare
)
end
end
end
def
fields
def
fields
...
@@ -59,4 +42,3 @@ class EmailsOnPushService < Service
...
@@ -59,4 +42,3 @@ class EmailsOnPushService < Service
]
]
end
end
end
end
app/workers/emails_on_push_worker.rb
0 → 100644
View file @
6ac73f45
class
EmailsOnPushWorker
include
Sidekiq
::
Worker
def
perform
(
project_id
,
recipients
,
push_data
)
project
=
Project
.
find
(
project_id
)
before_sha
=
push_data
[
"before"
]
after_sha
=
push_data
[
"after"
]
branch
=
push_data
[
"ref"
]
author_id
=
push_data
[
"user_id"
]
if
before_sha
=~
/^000000/
||
after_sha
=~
/^000000/
# skip if new branch was pushed or branch was removed
return
true
end
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?
recipients
.
split
(
" "
).
each
do
|
recipient
|
Notify
.
delay
.
repository_push_email
(
project_id
,
recipient
,
author_id
,
branch
,
compare
)
end
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