Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-09-06 18:30:44 +0300
committerShinya Maeda <shinya@gitlab.com>2017-09-06 18:30:44 +0300
commitc4c383e6d5e38de260434fe414fbdbe02d0e3763 (patch)
treec827391638fc8f2180f2345e2fb0aa3677d7de90
parent4b8c52f2fc13711ca54bd5274bc1041f69607eb5 (diff)
Revert set_protected
-rw-r--r--app/models/ci/build.rb6
-rw-r--r--app/models/ci/pipeline.rb6
-rw-r--r--app/services/ci/create_pipeline_service.rb3
-rw-r--r--lib/gitlab/ci/stage/seed.rb9
4 files changed, 12 insertions, 12 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 11390d3aa0d..ba3156154ac 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -27,6 +27,7 @@ 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) }
@@ -46,7 +47,6 @@ 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,10 +461,6 @@ module Ci
end
end
- def set_protected
- self.protected = pipeline.protected
- end
-
def erase_trace!
trace.erase!
end
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index fe8f12df70b..35d14b6e297 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -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,10 +445,6 @@ 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
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index de2cd7e87be..414c01b2546 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -12,7 +12,8 @@ module Ci
tag: tag?,
trigger_requests: Array(trigger_request),
user: current_user,
- pipeline_schedule: schedule
+ pipeline_schedule: schedule,
+ protected: project.protected_for?(ref)
)
result = validate(current_user,
diff --git a/lib/gitlab/ci/stage/seed.rb b/lib/gitlab/ci/stage/seed.rb
index f81f9347b4d..e19aae35a81 100644
--- a/lib/gitlab/ci/stage/seed.rb
+++ b/lib/gitlab/ci/stage/seed.rb
@@ -28,7 +28,8 @@ module Gitlab
attributes.merge(project: project,
ref: pipeline.ref,
tag: pipeline.tag,
- trigger_request: trigger)
+ trigger_request: trigger,
+ protected: protected_ref?)
end
end
@@ -43,6 +44,12 @@ module Gitlab
end
end
end
+
+ private
+
+ def protected_ref?
+ @protected_ref ||= project.protected_for?(pipeline.ref)
+ end
end
end
end