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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
74fd5cab
Commit
74fd5cab
authored
Oct 08, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve transitions and run hooks after transaction
parent
04afdb61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
app/models/commit_status.rb
app/models/commit_status.rb
+20
-18
No files found.
app/models/commit_status.rb
View file @
74fd5cab
...
@@ -85,33 +85,35 @@ class CommitStatus < ActiveRecord::Base
...
@@ -85,33 +85,35 @@ class CommitStatus < ActiveRecord::Base
commit_status
.
update_attributes
finished_at:
Time
.
now
commit_status
.
update_attributes
finished_at:
Time
.
now
end
end
after_transition
do
|
commit_status
|
commit_status
.
run_after_commit
do
pipeline
.
try
do
|
pipeline
|
if
complete?
ProcessPipelineWorker
.
perform_async
(
pipeline
.
id
)
else
UpdatePipelineWorker
.
perform_async
(
pipeline
.
id
)
end
end
end
end
after_transition
[
:created
,
:pending
,
:running
]
=>
:success
do
|
commit_status
|
after_transition
[
:created
,
:pending
,
:running
]
=>
:success
do
|
commit_status
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
trigger
(
commit_status
)
commit_status
.
run_after_commit
do
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
pipeline
.
project
,
nil
).
trigger
(
self
)
end
end
end
after_transition
any
=>
:failed
do
|
commit_status
|
after_transition
any
=>
:failed
do
|
commit_status
|
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
execute
(
commit_status
)
commit_status
.
run_after_commit
do
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
pipeline
.
project
,
nil
).
execute
(
self
)
end
end
end
after_transition
do: :schedule_pipeline_update
end
end
delegate
:sha
,
:short_sha
,
to: :pipeline
delegate
:sha
,
:short_sha
,
to: :pipeline
def
schedule_pipeline_update
run_after_commit
(
:process_pipeline!
)
end
def
process_pipeline!
pipeline
.
try
do
|
pipeline
|
if
complete?
ProcessPipelineWorker
.
perform_async
(
pipeline
.
id
)
else
UpdatePipelineWorker
.
perform_async
(
pipeline
.
id
)
end
end
end
def
before_sha
def
before_sha
pipeline
.
before_sha
||
Gitlab
::
Git
::
BLANK_SHA
pipeline
.
before_sha
||
Gitlab
::
Git
::
BLANK_SHA
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