diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 03:06:28 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 03:06:28 +0000 |
commit | 0ecdcf59f4342de55a7d2c3ee4ac0d9c3b116aa5 (patch) | |
tree | 07b26906534f336e9dcd708afbeef8612d1c93f2 /app | |
parent | 5a3f1ba53bf875a73f800909e8559d15dfab4339 (diff) | |
download | gitlab-ce-0ecdcf59f4342de55a7d2c3ee4ac0d9c3b116aa5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 3 | ||||
-rw-r--r-- | app/models/ci/persistent_ref.rb | 12 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 3 |
3 files changed, 15 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 59a2c09bd28..59bff4e2d2b 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -247,10 +247,11 @@ module Ci end after_transition pending: :running do |build| - build.pipeline.persistent_ref.create build.deployment&.run build.run_after_commit do + build.pipeline.persistent_ref.create + BuildHooksWorker.perform_async(id) end end diff --git a/app/models/ci/persistent_ref.rb b/app/models/ci/persistent_ref.rb index be3d4aa3203..54c3135ac9e 100644 --- a/app/models/ci/persistent_ref.rb +++ b/app/models/ci/persistent_ref.rb @@ -14,13 +14,15 @@ module Ci delegate :ref_exists?, :create_ref, :delete_refs, to: :repository def exist? + return unless enabled? + ref_exists?(path) rescue false end def create - return if exist? + return unless enabled? && !exist? create_ref(sha, path) rescue => e @@ -29,6 +31,8 @@ module Ci end def delete + return unless enabled? + delete_refs(path) rescue Gitlab::Git::Repository::NoRepository # no-op @@ -40,5 +44,11 @@ module Ci def path "refs/#{Repository::REF_PIPELINES}/#{pipeline.id}" end + + private + + def enabled? + Feature.enabled?(:depend_on_persistent_pipeline_ref, project, default_enabled: true) + end end end diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index 70ce4df5678..e91a529fecc 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -49,13 +49,14 @@ class MergeRequestDiff < ApplicationRecord scope :by_commit_sha, ->(sha) do joins(:merge_request_diff_commits).where(merge_request_diff_commits: { sha: sha }).reorder(nil) end + scope :has_diff_files, -> { where(id: MergeRequestDiffFile.select(:merge_request_diff_id)) } scope :by_project_id, -> (project_id) do joins(:merge_request).where(merge_requests: { target_project_id: project_id }) end scope :recent, -> { order(id: :desc).limit(100) } - scope :files_in_database, -> { where(stored_externally: [false, nil]) } + scope :files_in_database, -> { has_diff_files.where(stored_externally: [false, nil]) } scope :not_latest_diffs, -> do merge_requests = MergeRequest.arel_table |