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
Tatuya Kamada
gitlab-ce
Commits
b1dc850a
Commit
b1dc850a
authored
Mar 18, 2017
by
Rydkin Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move `auto_cancelable_pipelines` method to `create_pipeline_service.rb`
parent
c77b1cb0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+0
-8
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+9
-2
No files found.
app/models/ci/pipeline.rb
View file @
b1dc850a
...
...
@@ -127,14 +127,6 @@ module Ci
where
.
not
(
duration:
nil
).
sum
(
:duration
)
end
def
auto_cancelable_pipelines
project
.
pipelines
.
where
(
ref:
ref
)
.
where
.
not
(
id:
id
)
.
where
.
not
(
sha:
project
.
repository
.
sha_from_ref
(
ref
))
.
created_or_pending
end
def
stage
(
name
)
stage
=
Ci
::
Stage
.
new
(
self
,
name:
name
)
stage
unless
stage
.
statuses_count
.
zero?
...
...
app/services/ci/create_pipeline_service.rb
View file @
b1dc850a
...
...
@@ -66,8 +66,7 @@ module Ci
end
def
cancel_pending_pipelines
Gitlab
::
OptimisticLocking
.
retry_lock
(
pipeline
.
auto_cancelable_pipelines
)
do
|
cancelables
|
Gitlab
::
OptimisticLocking
.
retry_lock
(
auto_cancelable_pipelines
)
do
|
cancelables
|
cancelables
.
find_each
do
|
cancelable
|
cancelable
.
cancel_running
cancelable
.
update_attributes
(
auto_canceled_by:
pipeline
.
id
)
...
...
@@ -75,6 +74,14 @@ module Ci
end
end
def
auto_cancelable_pipelines
project
.
pipelines
.
where
(
ref:
pipeline
.
ref
)
.
where
.
not
(
id:
pipeline
.
id
)
.
where
.
not
(
sha:
project
.
repository
.
sha_from_ref
(
pipeline
.
ref
))
.
created_or_pending
end
def
commit
@commit
||=
project
.
commit
(
origin_sha
||
origin_ref
)
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