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
f7da15ba
Commit
f7da15ba
authored
Sep 06, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use before_save :set_protected
parent
d68ff7f5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
12 deletions
+23
-12
app/models/ci/build.rb
app/models/ci/build.rb
+5
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+5
-1
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-2
lib/gitlab/ci/stage/seed.rb
lib/gitlab/ci/stage/seed.rb
+1
-8
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+11
-0
No files found.
app/models/ci/build.rb
View file @
f7da15ba
...
...
@@ -27,7 +27,6 @@ module Ci
validates
:coverage
,
numericality:
true
,
allow_blank:
true
validates
:ref
,
presence:
true
validates
:protected
,
inclusion:
{
in:
[
true
,
false
],
unless: :importing?
},
on: :create
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
...
...
@@ -47,6 +46,7 @@ module Ci
before_save
:update_artifacts_size
,
if: :artifacts_file_changed?
before_save
:ensure_token
before_save
:set_protected
before_destroy
{
unscoped_project
}
after_create
do
|
build
|
...
...
@@ -461,6 +461,10 @@ module Ci
end
end
def
set_protected
self
.
protected
=
pipeline
.
protected
end
def
erase_trace!
trace
.
erase!
end
...
...
app/models/ci/pipeline.rb
View file @
f7da15ba
...
...
@@ -36,9 +36,9 @@ module Ci
validates
:sha
,
presence:
{
unless: :importing?
}
validates
:ref
,
presence:
{
unless: :importing?
}
validates
:status
,
presence:
{
unless: :importing?
}
validates
:protected
,
inclusion:
{
in:
[
true
,
false
],
unless: :importing?
},
on: :create
validate
:valid_commit_sha
,
unless: :importing?
# before_save :set_protected
after_create
:keep_around_commits
,
unless: :importing?
enum
source:
{
...
...
@@ -445,6 +445,10 @@ module Ci
statuses
.
latest
.
status
||
'skipped'
end
def
set_protected
self
.
protected
=
project
.
protected_for?
(
self
.
ref
)
end
def
keep_around_commits
return
unless
project
...
...
app/services/ci/create_pipeline_service.rb
View file @
f7da15ba
...
...
@@ -12,8 +12,7 @@ module Ci
tag:
tag?
,
trigger_requests:
Array
(
trigger_request
),
user:
current_user
,
pipeline_schedule:
schedule
,
protected:
project
.
protected_for?
(
ref
)
pipeline_schedule:
schedule
)
result
=
validate
(
current_user
,
...
...
lib/gitlab/ci/stage/seed.rb
View file @
f7da15ba
...
...
@@ -28,8 +28,7 @@ module Gitlab
attributes
.
merge
(
project:
project
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
trigger_request:
trigger
,
protected:
protected_ref?
)
trigger_request:
trigger
)
end
end
...
...
@@ -44,12 +43,6 @@ module Gitlab
end
end
end
private
def
protected_ref?
@protected_ref
||=
project
.
protected_for?
(
pipeline
.
ref
)
end
end
end
end
...
...
spec/services/ci/retry_build_service_spec.rb
View file @
f7da15ba
...
...
@@ -52,6 +52,17 @@ describe Ci::RetryBuildService do
expect
(
new_build
.
send
(
attribute
)).
to
eq
build
.
send
(
attribute
)
end
end
context
'when job has nullified protected'
do
before
do
build
.
update_attribute
(
:protected
,
nil
)
end
it
"clones protected build attribute"
do
expect
(
new_build
.
protected
).
not_to
be_nil
expect
(
new_build
.
protected
).
to
eq
build
.
protected
end
end
end
describe
'reject acessors'
do
...
...
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