Commit 55693cc1 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent c089cf73
......@@ -39,7 +39,7 @@ class PipelinesFinder
# rubocop: disable CodeReuse/ActiveRecord
def from_ids(ids)
pipelines.unscoped.where(id: ids)
pipelines.unscoped.where(project_id: project.id, id: ids)
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -12,7 +12,7 @@ module Issuable
def execute
update_attributes = { labels: cloneable_labels }
milestone = cloneable_milestone
milestone = matching_milestone(original_entity.milestone&.title)
update_attributes[:milestone] = milestone if milestone.present?
new_entity.update(update_attributes)
......@@ -23,11 +23,8 @@ module Issuable
private
def cloneable_milestone
return unless new_entity.supports_milestone?
title = original_entity.milestone&.title
return unless title
def matching_milestone(title)
return if title.blank? || !new_entity.supports_milestone?
params = { title: title, project_ids: new_entity.project&.id, group_ids: group&.id }
......@@ -49,29 +46,32 @@ module Issuable
end
def copy_resource_label_events
original_entity.resource_label_events.find_in_batches do |batch|
events = batch.map do |event|
entity_key = new_entity.is_a?(Issue) ? 'issue_id' : 'epic_id'
event.attributes
.except('id', 'reference', 'reference_html')
.merge(entity_key => new_entity.id, 'action' => ResourceLabelEvent.actions[event.action])
end
entity_key = new_entity.class.name.underscore.foreign_key
Gitlab::Database.bulk_insert(ResourceLabelEvent.table_name, events)
copy_events(ResourceLabelEvent.table_name, original_entity.resource_label_events) do |event|
event.attributes
.except('id', 'reference', 'reference_html')
.merge(entity_key => new_entity.id, 'action' => ResourceLabelEvent.actions[event.action])
end
end
def copy_resource_weight_events
return unless original_entity.respond_to?(:resource_weight_events)
original_entity.resource_weight_events.find_in_batches do |batch|
copy_events(ResourceWeightEvent.table_name, original_entity.resource_weight_events) do |event|
event.attributes
.except('id', 'reference', 'reference_html')
.merge('issue_id' => new_entity.id)
end
end
def copy_events(table_name, events_to_copy)
events_to_copy.find_in_batches do |batch|
events = batch.map do |event|
event.attributes
.except('id', 'reference', 'reference_html')
.merge('issue_id' => new_entity.id)
end
yield(event)
end.compact
Gitlab::Database.bulk_insert(ResourceWeightEvent.table_name, events)
Gitlab::Database.bulk_insert(table_name, events)
end
end
......
---
title: Search group-level objects among all ancestors during project import
merge_request:
author:
type: changed
---
title: Fix query performance in PipelinesFinder
merge_request: 21092
author:
type: performance
---
title: Remove unneeded indexes on projects table
merge_request: 24086
author:
type: performance
......@@ -16,6 +16,10 @@ To spread load more evenly across eligible reviewers, Danger has randomly picked
a candidate for each review slot. Feel free to override this selection if you
think someone else would be better-suited, or the chosen person is unavailable.
To read more on how to use the reviewer roulette, please take a look at the
[Engineering workflow](https://about.gitlab.com/handbook/engineering/workflow/#basics)
and [code review guidelines](https://docs.gitlab.com/ee/development/code_review.html).
Once you've decided who will review this merge request, mention them as you
normally would! Danger does not (yet?) automatically notify them for you.
......
# frozen_string_literal: true
class DropUnneededIndexesForProjectsApiRequests < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
indexes = %w(
index_projects_api_vis20_created_at_id_desc
index_projects_api_vis20_last_activity_at_id_desc
index_projects_api_vis20_updated_at_id_desc
index_projects_api_vis20_name_id_desc
index_projects_api_vis20_path_id_desc
)
indexes.each do |index|
remove_concurrent_index_by_name :projects, index
end
end
def down
columns = %i(created_at last_activity_at updated_at name path)
columns.each do |column|
add_concurrent_index :projects, [column, :id], where: 'visibility_level = 20', order: { id: :desc }, name: "index_projects_api_vis20_#{column}_id_desc"
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_01_29_035708) do
ActiveRecord::Schema.define(version: 2020_01_30_161817) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
......@@ -3382,7 +3382,6 @@ ActiveRecord::Schema.define(version: 2020_01_29_035708) do
t.index "lower((name)::text)", name: "index_projects_on_lower_name"
t.index ["created_at", "id"], name: "index_projects_api_created_at_id_desc", order: { id: :desc }
t.index ["created_at", "id"], name: "index_projects_api_vis20_created_at", where: "(visibility_level = 20)"
t.index ["created_at", "id"], name: "index_projects_api_vis20_created_at_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["created_at", "id"], name: "index_projects_on_created_at_and_id"
t.index ["creator_id"], name: "index_projects_on_creator_id"
t.index ["description"], name: "index_projects_on_description_trigram", opclass: :gin_trgm_ops, using: :gin
......@@ -3392,7 +3391,6 @@ ActiveRecord::Schema.define(version: 2020_01_29_035708) do
t.index ["id"], name: "index_projects_on_mirror_and_mirror_trigger_builds_both_true", where: "((mirror IS TRUE) AND (mirror_trigger_builds IS TRUE))"
t.index ["last_activity_at", "id"], name: "index_projects_api_last_activity_at_id_desc", order: { id: :desc }
t.index ["last_activity_at", "id"], name: "index_projects_api_vis20_last_activity_at", where: "(visibility_level = 20)"
t.index ["last_activity_at", "id"], name: "index_projects_api_vis20_last_activity_at_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["last_activity_at", "id"], name: "index_projects_on_last_activity_at_and_id"
t.index ["last_repository_check_at"], name: "index_projects_on_last_repository_check_at", where: "(last_repository_check_at IS NOT NULL)"
t.index ["last_repository_check_failed"], name: "index_projects_on_last_repository_check_failed"
......@@ -3403,13 +3401,11 @@ ActiveRecord::Schema.define(version: 2020_01_29_035708) do
t.index ["mirror_user_id"], name: "index_projects_on_mirror_user_id"
t.index ["name", "id"], name: "index_projects_api_name_id_desc", order: { id: :desc }
t.index ["name", "id"], name: "index_projects_api_vis20_name", where: "(visibility_level = 20)"
t.index ["name", "id"], name: "index_projects_api_vis20_name_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["name", "id"], name: "index_projects_on_name_and_id"
t.index ["name"], name: "index_projects_on_name_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["namespace_id"], name: "index_projects_on_namespace_id"
t.index ["path", "id"], name: "index_projects_api_path_id_desc", order: { id: :desc }
t.index ["path", "id"], name: "index_projects_api_vis20_path", where: "(visibility_level = 20)"
t.index ["path", "id"], name: "index_projects_api_vis20_path_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["path", "id"], name: "index_projects_on_path_and_id"
t.index ["path"], name: "index_projects_on_path_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["pending_delete"], name: "index_projects_on_pending_delete"
......@@ -3421,7 +3417,6 @@ ActiveRecord::Schema.define(version: 2020_01_29_035708) do
t.index ["star_count"], name: "index_projects_on_star_count"
t.index ["updated_at", "id"], name: "index_projects_api_updated_at_id_desc", order: { id: :desc }
t.index ["updated_at", "id"], name: "index_projects_api_vis20_updated_at", where: "(visibility_level = 20)"
t.index ["updated_at", "id"], name: "index_projects_api_vis20_updated_at_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["updated_at", "id"], name: "index_projects_on_updated_at_and_id"
end
......
......@@ -4,7 +4,9 @@
You're strongly advised to install
[Overcommit](https://github.com/sds/overcommit) to automatically check for
static analysis offenses before committing locally:
static analysis offenses before committing locally.
In your GitLab source directory run:
```shell
cd tooling/overcommit && make && cd -
......
......@@ -52,9 +52,9 @@ Web servers can take advantages of middlewares like [Secure](https://github.com/
Many of our projects are too small to have full-time maintainers. That's why we
have a shared pool of Go reviewers at GitLab. To find a reviewer, use the
[Engineering Projects](https://about.gitlab.com/handbook/engineering/projects/)
page in the handbook. "GitLab Community Edition (CE)" and "GitLab Community
Edition (EE)" both have a "Go" section with its list of reviewers.
["Go" section](https://about.gitlab.com/handbook/engineering/projects/#gitlab_reviewers_go)
of the "GitLab" project on the Engineering Projects
page in the handbook.
To add yourself to this list, add the following to your profile in the
[team.yml](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/team.yml)
......
......@@ -896,6 +896,11 @@ Reference-style (hover to see title text):
[logo]: img/markdown_logo.png "Title Text"
```
<!--
DO NOT change the name of markdown_logo.png. This is used for a test
in spec/controllers/help_controller_spec.rb.
-->
Inline-style (hover to see title text):
![alt text](img/markdown_logo.png "Title Text")
......
......@@ -50,7 +50,7 @@ module Gitlab
def where_clause_base
[].tap do |clauses|
clauses << table[:project_id].eq(project.id) if project
clauses << table[:group_id].eq(group.id) if group
clauses << table[:group_id].in(group.self_and_ancestors_ids) if group
end.reduce(:or)
end
......@@ -60,7 +60,9 @@ module Gitlab
end
def prepare_attributes
attributes.except('group').tap do |atts|
attributes.dup.tap do |atts|
atts.delete('group') unless epic?
if label?
atts['type'] = 'ProjectLabel' # Always create project labels
elsif milestone?
......
......@@ -111,7 +111,7 @@ describe HelpController do
it 'renders the raw file' do
get :show,
params: {
path: 'fixtures/gitlab_tanuki'
path: 'user/img/markdown_logo'
},
format: :png
expect(response).to be_successful
......
......@@ -3,13 +3,15 @@
require 'spec_helper'
describe Gitlab::ImportExport::GroupProjectObjectBuilder do
let(:project) do
let!(:group) { create(:group, :private) }
let!(:subgroup) { create(:group, :private, parent: group) }
let!(:project) do
create(:project, :repository,
:builds_disabled,
:issues_disabled,
name: 'project',
path: 'project',
group: create(:group))
group: subgroup)
end
let(:lru_cache) { subject.send(:lru_cache) }
......@@ -75,6 +77,15 @@ describe Gitlab::ImportExport::GroupProjectObjectBuilder do
'group' => project.group)).to eq(group_label)
end
it 'finds the existing group label in root ancestor' do
group_label = create(:group_label, name: 'group label', group: group)
expect(described_class.build(Label,
'title' => 'group label',
'project' => project,
'group' => group)).to eq(group_label)
end
it 'creates a new label' do
label = described_class.build(Label,
'title' => 'group label',
......@@ -95,6 +106,15 @@ describe Gitlab::ImportExport::GroupProjectObjectBuilder do
'group' => project.group)).to eq(milestone)
end
it 'finds the existing group milestone in root ancestor' do
milestone = create(:milestone, name: 'group milestone', group: group)
expect(described_class.build(Milestone,
'title' => 'group milestone',
'project' => project,
'group' => group)).to eq(milestone)
end
it 'creates a new milestone' do
milestone = described_class.build(Milestone,
'title' => 'group milestone',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment