Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
ca05512007
commit
51612d3ef5
16 changed files with 228 additions and 2 deletions
|
@ -2299,6 +2299,10 @@ class Project < ApplicationRecord
|
|||
false
|
||||
end
|
||||
|
||||
def uses_default_ci_config?
|
||||
ci_config_path.blank? || ci_config_path == Gitlab::FileDetector::PATTERNS[:gitlab_ci]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def closest_namespace_setting(name)
|
||||
|
|
|
@ -50,6 +50,19 @@ class MergeRequestWidgetEntity < Grape::Entity
|
|||
ci_environments_status_project_merge_request_path(merge_request.project, merge_request)
|
||||
end
|
||||
|
||||
expose :merge_request_add_ci_config_path, if: ->(mr, _) { can_add_ci_config_path?(mr) } do |merge_request|
|
||||
project_new_blob_path(
|
||||
merge_request.source_project,
|
||||
merge_request.source_branch,
|
||||
file_name: '.gitlab-ci.yml',
|
||||
commit_message: s_("CommitMessage|Add %{file_name}") % { file_name: Gitlab::FileDetector::PATTERNS[:gitlab_ci] }
|
||||
)
|
||||
end
|
||||
|
||||
expose :human_access do |merge_request|
|
||||
merge_request.project.team.human_max_access(current_user&.id)
|
||||
end
|
||||
|
||||
# Rendering and redacting Markdown can be expensive. These links are
|
||||
# just nice to have in the merge request widget, so only
|
||||
# include them if they are explicitly requested on first load.
|
||||
|
@ -75,6 +88,13 @@ class MergeRequestWidgetEntity < Grape::Entity
|
|||
@presenters ||= {}
|
||||
@presenters[merge_request] ||= MergeRequestPresenter.new(merge_request, current_user: current_user) # rubocop: disable CodeReuse/Presenter
|
||||
end
|
||||
|
||||
def can_add_ci_config_path?(merge_request)
|
||||
merge_request.source_project&.uses_default_ci_config? &&
|
||||
merge_request.all_pipelines.none? &&
|
||||
merge_request.commits_count.positive? &&
|
||||
can?(current_user, :push_code, merge_request.source_project)
|
||||
end
|
||||
end
|
||||
|
||||
MergeRequestWidgetEntity.prepend_if_ee('EE::MergeRequestWidgetEntity')
|
||||
|
|
5
changelogs/unreleased/196243-add-exclusive-guard.yml
Normal file
5
changelogs/unreleased/196243-add-exclusive-guard.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix race condition bug in Prometheus managed app update process
|
||||
merge_request: 24228
|
||||
author:
|
||||
type: fixed
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Query projects of subgroups in Cycle Analytics
|
||||
merge_request: 24392
|
||||
author:
|
||||
type: fixed
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: 'Geo: Add tables to prepare to replicate package files'
|
||||
merge_request: 23447
|
||||
author:
|
||||
type: added
|
|
@ -55,6 +55,8 @@ module Gitlab
|
|||
memo << ee_path.to_s
|
||||
end
|
||||
|
||||
ee_paths << "ee/app/replicators"
|
||||
|
||||
# Eager load should load CE first
|
||||
config.eager_load_paths.push(*ee_paths)
|
||||
config.helpers_paths.push "#{config.root}/ee/app/helpers"
|
||||
|
|
|
@ -19,6 +19,7 @@ ActiveSupport::Inflector.inflections do |inflect|
|
|||
group_view
|
||||
job_artifact_registry
|
||||
lfs_object_registry
|
||||
package_file_registry
|
||||
project_auto_devops
|
||||
project_registry
|
||||
project_statistics
|
||||
|
|
14
db/migrate/20200121192942_create_geo_events.rb
Normal file
14
db/migrate/20200121192942_create_geo_events.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateGeoEvents < ActiveRecord::Migration[5.2]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
create_table :geo_events do |t|
|
||||
t.string :replicable_name, limit: 255, null: false
|
||||
t.string :event_name, limit: 255, null: false
|
||||
t.jsonb :payload, default: {}, null: false
|
||||
t.datetime_with_timezone :created_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGeoEventIdToGeoEventLog < ActiveRecord::Migration[5.2]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :geo_event_log, :geo_event_id, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGeoEventIdIndexToGeoEventLog < ActiveRecord::Migration[5.2]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_index :geo_event_log, :geo_event_id,
|
||||
where: "(geo_event_id IS NOT NULL)",
|
||||
using: :btree,
|
||||
name: 'index_geo_event_log_on_geo_event_id'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index :geo_event_log, :geo_event_id, name: 'index_geo_event_log_on_geo_event_id'
|
||||
end
|
||||
end
|
20
db/migrate/20200121194154_add_geo_events_foreign_key.rb
Normal file
20
db/migrate/20200121194154_add_geo_events_foreign_key.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGeoEventsForeignKey < ActiveRecord::Migration[5.2]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_foreign_key :geo_event_log, :geo_events,
|
||||
column: :geo_event_id,
|
||||
name: 'fk_geo_event_log_on_geo_event_id',
|
||||
on_delete: :cascade
|
||||
end
|
||||
|
||||
def down
|
||||
remove_foreign_key_without_error :geo_event_log, column: :geo_event_id, name: 'fk_geo_event_log_on_geo_event_id'
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -1665,8 +1665,10 @@ ActiveRecord::Schema.define(version: 2020_02_03_025821) do
|
|||
t.bigint "reset_checksum_event_id"
|
||||
t.bigint "cache_invalidation_event_id"
|
||||
t.bigint "container_repository_updated_event_id"
|
||||
t.integer "geo_event_id"
|
||||
t.index ["cache_invalidation_event_id"], name: "index_geo_event_log_on_cache_invalidation_event_id", where: "(cache_invalidation_event_id IS NOT NULL)"
|
||||
t.index ["container_repository_updated_event_id"], name: "index_geo_event_log_on_container_repository_updated_event_id"
|
||||
t.index ["geo_event_id"], name: "index_geo_event_log_on_geo_event_id", where: "(geo_event_id IS NOT NULL)"
|
||||
t.index ["hashed_storage_attachments_event_id"], name: "index_geo_event_log_on_hashed_storage_attachments_event_id", where: "(hashed_storage_attachments_event_id IS NOT NULL)"
|
||||
t.index ["hashed_storage_migrated_event_id"], name: "index_geo_event_log_on_hashed_storage_migrated_event_id", where: "(hashed_storage_migrated_event_id IS NOT NULL)"
|
||||
t.index ["job_artifact_deleted_event_id"], name: "index_geo_event_log_on_job_artifact_deleted_event_id", where: "(job_artifact_deleted_event_id IS NOT NULL)"
|
||||
|
@ -1680,6 +1682,13 @@ ActiveRecord::Schema.define(version: 2020_02_03_025821) do
|
|||
t.index ["upload_deleted_event_id"], name: "index_geo_event_log_on_upload_deleted_event_id", where: "(upload_deleted_event_id IS NOT NULL)"
|
||||
end
|
||||
|
||||
create_table "geo_events", force: :cascade do |t|
|
||||
t.string "replicable_name", limit: 255, null: false
|
||||
t.string "event_name", limit: 255, null: false
|
||||
t.jsonb "payload", default: {}, null: false
|
||||
t.datetime_with_timezone "created_at", null: false
|
||||
end
|
||||
|
||||
create_table "geo_hashed_storage_attachments_events", force: :cascade do |t|
|
||||
t.integer "project_id", null: false
|
||||
t.text "old_attachments_path", null: false
|
||||
|
@ -4620,6 +4629,7 @@ ActiveRecord::Schema.define(version: 2020_02_03_025821) do
|
|||
add_foreign_key "geo_container_repository_updated_events", "container_repositories", name: "fk_212c89c706", on_delete: :cascade
|
||||
add_foreign_key "geo_event_log", "geo_cache_invalidation_events", column: "cache_invalidation_event_id", name: "fk_42c3b54bed", on_delete: :cascade
|
||||
add_foreign_key "geo_event_log", "geo_container_repository_updated_events", column: "container_repository_updated_event_id", name: "fk_6ada82d42a", on_delete: :cascade
|
||||
add_foreign_key "geo_event_log", "geo_events", name: "fk_geo_event_log_on_geo_event_id", on_delete: :cascade
|
||||
add_foreign_key "geo_event_log", "geo_hashed_storage_migrated_events", column: "hashed_storage_migrated_event_id", name: "fk_27548c6db3", on_delete: :cascade
|
||||
add_foreign_key "geo_event_log", "geo_job_artifact_deleted_events", column: "job_artifact_deleted_event_id", name: "fk_176d3fbb5d", on_delete: :cascade
|
||||
add_foreign_key "geo_event_log", "geo_lfs_object_deleted_events", column: "lfs_object_deleted_event_id", name: "fk_d5af95fcd9", on_delete: :cascade
|
||||
|
|
|
@ -27,6 +27,7 @@ module Quality
|
|||
policies
|
||||
presenters
|
||||
rack_servers
|
||||
replicators
|
||||
routing
|
||||
rubocop
|
||||
serializers
|
||||
|
|
|
@ -21,7 +21,7 @@ RSpec.describe Quality::TestLevel do
|
|||
context 'when level is unit' do
|
||||
it 'returns a pattern' do
|
||||
expect(subject.pattern(:unit))
|
||||
.to eq("spec/{bin,config,db,dependencies,factories,finders,frontend,graphql,haml_lint,helpers,initializers,javascripts,lib,models,policies,presenters,rack_servers,routing,rubocop,serializers,services,sidekiq,tasks,uploaders,validators,views,workers,elastic_integration}{,/**/}*_spec.rb")
|
||||
.to eq("spec/{bin,config,db,dependencies,factories,finders,frontend,graphql,haml_lint,helpers,initializers,javascripts,lib,models,policies,presenters,rack_servers,replicators,routing,rubocop,serializers,services,sidekiq,tasks,uploaders,validators,views,workers,elastic_integration}{,/**/}*_spec.rb")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -82,7 +82,7 @@ RSpec.describe Quality::TestLevel do
|
|||
context 'when level is unit' do
|
||||
it 'returns a regexp' do
|
||||
expect(subject.regexp(:unit))
|
||||
.to eq(%r{spec/(bin|config|db|dependencies|factories|finders|frontend|graphql|haml_lint|helpers|initializers|javascripts|lib|models|policies|presenters|rack_servers|routing|rubocop|serializers|services|sidekiq|tasks|uploaders|validators|views|workers|elastic_integration)})
|
||||
.to eq(%r{spec/(bin|config|db|dependencies|factories|finders|frontend|graphql|haml_lint|helpers|initializers|javascripts|lib|models|policies|presenters|rack_servers|replicators|routing|rubocop|serializers|services|sidekiq|tasks|uploaders|validators|views|workers|elastic_integration)})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2095,6 +2095,28 @@ describe Project do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#uses_default_ci_config?' do
|
||||
let(:project) { build(:project)}
|
||||
|
||||
it 'has a custom ci config path' do
|
||||
project.ci_config_path = 'something_custom'
|
||||
|
||||
expect(project.uses_default_ci_config?).to be_falsey
|
||||
end
|
||||
|
||||
it 'has a blank ci config path' do
|
||||
project.ci_config_path = ''
|
||||
|
||||
expect(project.uses_default_ci_config?).to be_truthy
|
||||
end
|
||||
|
||||
it 'does not have a custom ci config path' do
|
||||
project.ci_config_path = nil
|
||||
|
||||
expect(project.uses_default_ci_config?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe '#latest_successful_build_for_ref' do
|
||||
let(:project) { create(:project, :repository) }
|
||||
let(:pipeline) { create_pipeline(project) }
|
||||
|
|
|
@ -53,6 +53,94 @@ describe MergeRequestWidgetEntity do
|
|||
.to eq("/#{resource.project.full_path}/-/merge_requests/#{resource.iid}.diff")
|
||||
end
|
||||
|
||||
describe 'merge_request_add_ci_config_path' do
|
||||
before do
|
||||
project.add_role(user, role)
|
||||
end
|
||||
|
||||
context 'when there are pipelines' do
|
||||
let(:role) { :developer }
|
||||
|
||||
before do
|
||||
create(:ci_empty_pipeline, project: project, sha: resource.all_commit_shas.first, ref: resource.source_branch)
|
||||
end
|
||||
|
||||
it 'no ci config path' do
|
||||
expect(subject[:merge_request_add_ci_config_path]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are no pipelines' do
|
||||
context 'when user has permissions' do
|
||||
let(:role) { :developer }
|
||||
|
||||
it 'has add ci config path' do
|
||||
expect(subject[:merge_request_add_ci_config_path])
|
||||
.to eq("/#{resource.project.full_path}/-/new/#{resource.source_branch}?commit_message=Add+.gitlab-ci.yml&file_name=.gitlab-ci.yml")
|
||||
end
|
||||
|
||||
context 'when source project is missing' do
|
||||
before do
|
||||
resource.source_project = nil
|
||||
end
|
||||
|
||||
it 'returns a blank ci config path' do
|
||||
expect(subject[:merge_request_add_ci_config_path]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are no commits' do
|
||||
before do
|
||||
allow(resource).to receive(:commits_count).and_return(0)
|
||||
end
|
||||
|
||||
it 'returns a blank ci config path' do
|
||||
expect(subject[:merge_request_add_ci_config_path]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ci_config_path is customized' do
|
||||
it 'has no path if ci_config_path is not set to our default setting' do
|
||||
project.ci_config_path = 'not_default'
|
||||
|
||||
expect(subject[:merge_request_add_ci_config_path]).to be_nil
|
||||
end
|
||||
|
||||
it 'has a path if ci_config_path unset' do
|
||||
expect(subject[:merge_request_add_ci_config_path]).not_to be_nil
|
||||
end
|
||||
|
||||
it 'has a path if ci_config_path is an empty string' do
|
||||
project.ci_config_path = ''
|
||||
|
||||
expect(subject[:merge_request_add_ci_config_path]).not_to be_nil
|
||||
end
|
||||
|
||||
it 'has a path if ci_config_path is set to our default file' do
|
||||
project.ci_config_path = Gitlab::FileDetector::PATTERNS[:gitlab_ci]
|
||||
|
||||
expect(subject[:merge_request_add_ci_config_path]).not_to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user does not have permissions' do
|
||||
let(:role) { :reporter }
|
||||
|
||||
it 'has add ci config path' do
|
||||
expect(subject[:merge_request_add_ci_config_path]).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'has human access' do
|
||||
project.add_maintainer(user)
|
||||
|
||||
expect(subject[:human_access])
|
||||
.to eq('Maintainer')
|
||||
end
|
||||
|
||||
describe 'when source project is deleted' do
|
||||
let(:project) { create(:project, :repository) }
|
||||
let(:forked_project) { fork_project(project) }
|
||||
|
|
Loading…
Reference in a new issue