diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 15:09:29 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 15:09:29 +0000 |
commit | 209bd8cf1f542f6ba2a069b368a9187faa871e96 (patch) | |
tree | 6b77dc8183135b8316cc70c8dbc9c4e7c18cf05a /lib | |
parent | a9ced7da447785c57477b3d8dbccc73a78cface1 (diff) | |
download | gitlab-ce-209bd8cf1f542f6ba2a069b368a9187faa871e96.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config/entry/include.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/ci/yaml_processor.rb | 48 | ||||
-rw-r--r-- | lib/gitlab/git/blob.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/git/diff_stats_collection.rb | 9 |
4 files changed, 50 insertions, 23 deletions
diff --git a/lib/gitlab/ci/config/entry/include.rb b/lib/gitlab/ci/config/entry/include.rb index cd09d83b728..9c2e5f641d0 100644 --- a/lib/gitlab/ci/config/entry/include.rb +++ b/lib/gitlab/ci/config/entry/include.rb @@ -15,6 +15,14 @@ module Gitlab validations do validates :config, hash_or_string: true validates :config, allowed_keys: ALLOWED_KEYS + + validate do + next unless config.is_a?(Hash) + + if config[:artifact] && config[:job].blank? + errors.add(:config, "must specify the job where to fetch the artifact from") + end + end end end end diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index 764047dae6d..933504ea82f 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -142,6 +142,7 @@ module Gitlab validate_job_stage!(name, job) validate_job_dependencies!(name, job) validate_job_needs!(name, job) + validate_dynamic_child_pipeline_dependencies!(name, job) validate_job_environment!(name, job) end end @@ -163,37 +164,50 @@ module Gitlab def validate_job_dependencies!(name, job) return unless job[:dependencies] - stage_index = @stages.index(job[:stage]) - job[:dependencies].each do |dependency| - raise ValidationError, "#{name} job: undefined dependency: #{dependency}" unless @jobs[dependency.to_sym] + validate_job_dependency!(name, dependency) + end + end - dependency_stage_index = @stages.index(@jobs[dependency.to_sym][:stage]) + def validate_dynamic_child_pipeline_dependencies!(name, job) + return unless includes = job.dig(:trigger, :include) - unless dependency_stage_index.present? && dependency_stage_index < stage_index - raise ValidationError, "#{name} job: dependency #{dependency} is not defined in prior stages" - end + Array(includes).each do |included| + next unless included.is_a?(Hash) + next unless dependency = included[:job] + + validate_job_dependency!(name, dependency) end end def validate_job_needs!(name, job) - return unless job.dig(:needs, :job) - - stage_index = @stages.index(job[:stage]) + return unless needs = job.dig(:needs, :job) - job.dig(:needs, :job).each do |need| - need_job_name = need[:name] + needs.each do |need| + validate_job_dependency!(name, need[:name], 'need') + end + end - raise ValidationError, "#{name} job: undefined need: #{need_job_name}" unless @jobs[need_job_name.to_sym] + def validate_job_dependency!(name, dependency, dependency_type = 'dependency') + unless @jobs[dependency.to_sym] + raise ValidationError, "#{name} job: undefined #{dependency_type}: #{dependency}" + end - needs_stage_index = @stages.index(@jobs[need_job_name.to_sym][:stage]) + job_stage_index = stage_index(name) + dependency_stage_index = stage_index(dependency) - unless needs_stage_index.present? && needs_stage_index < stage_index - raise ValidationError, "#{name} job: need #{need_job_name} is not defined in prior stages" - end + # A dependency might be defined later in the configuration + # with a stage that does not exist + unless dependency_stage_index.present? && dependency_stage_index < job_stage_index + raise ValidationError, "#{name} job: #{dependency_type} #{dependency} is not defined in prior stages" end end + def stage_index(name) + stage = @jobs.dig(name.to_sym, :stage) + @stages.index(stage) + end + def validate_job_environment!(name, job) return unless job[:environment] return unless job[:environment].is_a?(Hash) diff --git a/lib/gitlab/git/blob.rb b/lib/gitlab/git/blob.rb index 5579449bf57..1b49d356d29 100644 --- a/lib/gitlab/git/blob.rb +++ b/lib/gitlab/git/blob.rb @@ -86,12 +86,8 @@ module Gitlab # to the caller to limit the number of blobs and blob_size_limit. # def batch(repository, blob_references, blob_size_limit: MAX_DATA_DISPLAY_SIZE) - if Feature.enabled?(:blobs_fetch_in_batches, default_enabled: true) - blob_references.each_slice(BATCH_SIZE).flat_map do |refs| - repository.gitaly_blob_client.get_blobs(refs, blob_size_limit).to_a - end - else - repository.gitaly_blob_client.get_blobs(blob_references, blob_size_limit).to_a + blob_references.each_slice(BATCH_SIZE).flat_map do |refs| + repository.gitaly_blob_client.get_blobs(refs, blob_size_limit).to_a end end diff --git a/lib/gitlab/git/diff_stats_collection.rb b/lib/gitlab/git/diff_stats_collection.rb index 998c41497a2..7e49d79676e 100644 --- a/lib/gitlab/git/diff_stats_collection.rb +++ b/lib/gitlab/git/diff_stats_collection.rb @@ -22,6 +22,15 @@ module Gitlab @collection.map(&:path) end + def real_size + max_files = ::Commit.max_diff_options[:max_files] + if paths.size > max_files + "#{max_files}+" + else + paths.size.to_s + end + end + private def indexed_by_path |