Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-10-26 03:08:41 +00:00
parent a13d121380
commit 2761bde409
15 changed files with 137 additions and 76 deletions

View file

@ -1,5 +1,3 @@
import { joinPaths } from '~/lib/utils/url_utility';
function loadScript(path) {
const script = document.createElement('script');
script.type = 'application/javascript';
@ -19,11 +17,10 @@ export default function initSourcegraph() {
return;
}
const base = gon.asset_host || gon.gitlab_url;
const assetsUrl = joinPaths(base, '/assets/webpack/sourcegraph/');
const scriptPath = joinPaths(assetsUrl, 'scripts/integration.bundle.js');
const assetsUrl = new URL('/assets/webpack/sourcegraph/', window.location.href);
const scriptPath = new URL('scripts/integration.bundle.js', assetsUrl).href;
window.SOURCEGRAPH_ASSETS_URL = assetsUrl;
window.SOURCEGRAPH_ASSETS_URL = assetsUrl.href;
window.SOURCEGRAPH_URL = url;
window.SOURCEGRAPH_INTEGRATION = 'gitlab-integration';

View file

@ -117,8 +117,12 @@ class Namespace < ApplicationRecord
# query - The search query as a String.
#
# Returns an ActiveRecord::Relation.
def search(query)
fuzzy_search(query, [:name, :path])
def search(query, include_parents: false)
if include_parents
where(id: Route.fuzzy_search(query, [Route.arel_table[:path], Route.arel_table[:name]]).select(:source_id))
else
fuzzy_search(query, [:path, :name])
end
end
def clean_path(path)

View file

@ -0,0 +1,5 @@
---
title: Add fuzzy-search on full path in Groups API
merge_request: 45729
author:
type: changed

View file

@ -0,0 +1,5 @@
---
title: Deprecate support for Elasticsearch 6.x
merge_request: 45619
author:
type: deprecated

View file

@ -0,0 +1,18 @@
# frozen_string_literal: true
class AddIndexRouteOnNameTrigramToRoute < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_route_on_name_trigram'
disable_ddl_transaction!
def up
add_concurrent_index :routes, :name, name: INDEX_NAME, using: :gin, opclass: { name: :gin_trgm_ops }
end
def down
remove_concurrent_index_by_name(:routes, INDEX_NAME)
end
end

View file

@ -0,0 +1 @@
47158d21bd1a800e5a9da1bfea25870f14cc0b094e5f3e9a4b7608b8a9eca180

View file

@ -21616,6 +21616,8 @@ CREATE INDEX index_reviews_on_merge_request_id ON reviews USING btree (merge_req
CREATE INDEX index_reviews_on_project_id ON reviews USING btree (project_id);
CREATE INDEX index_route_on_name_trigram ON routes USING gin (name gin_trgm_ops);
CREATE UNIQUE INDEX index_routes_on_path ON routes USING btree (path);
CREATE INDEX index_routes_on_path_text_pattern_ops ON routes USING btree (path varchar_pattern_ops);

View file

@ -13,6 +13,9 @@ Keep your GitLab instance up and running smoothly.
you have been running a large GitLab server (thousands of users) since before
GitLab 7.3 we recommend cleaning up stale sessions to compact the Redis
database after you upgrade to GitLab 7.3.
- [Rake tasks](../../raketasks/README.md): Tasks for common administration and operational processes such as
[cleaning up unneeded items from GitLab instance](../../raketasks/cleanup.md), integrity checks,
and more.
- [Moving repositories](moving_repositories.md): Moving all repositories managed
by GitLab to another file system or another server.
- [Sidekiq MemoryKiller](sidekiq_memory_killer.md): Configure Sidekiq MemoryKiller
@ -28,6 +31,8 @@ Keep your GitLab instance up and running smoothly.
performance can have a big impact on GitLab performance, especially for actions
that read or write Git repositories. This information will help benchmark
filesystem performance against known good and bad real-world systems.
- [The Rails Console](rails_console.md): Provides a way to interact with your GitLab instance from the command line.
Used for troubleshooting a problem or retrieving some data that can only be done through direct access to GitLab.
- [ChatOps Scripts](https://gitlab.com/gitlab-com/chatops): The GitLab.com Infrastructure team uses this repository to house
common ChatOps scripts they use to troubleshoot and maintain the production instance of GitLab.com.
These scripts are likely useful to administrators of GitLab instances of all sizes.

View file

@ -23,7 +23,9 @@ and the advantage of the following special searches:
| GitLab version | Elasticsearch version |
|---------------------------------------------|-------------------------------|
| GitLab Enterprise Edition 12.7 or greater | Elasticsearch 6.x through 7.x |
| GitLab Enterprise Edition 13.6 or greater | Elasticsearch 7.x (6.4 - 6.x deprecated to be removed in 13.8) |
| GitLab Enterprise Edition 13.2 through 13.5 | Elasticsearch 6.4 through 7.x |
| GitLab Enterprise Edition 12.7 through 13.2 | Elasticsearch 6.x through 7.x |
| GitLab Enterprise Edition 11.5 through 12.6 | Elasticsearch 5.6 through 6.x |
| GitLab Enterprise Edition 9.0 through 11.4 | Elasticsearch 5.1 through 5.5 |
| GitLab Enterprise Edition 8.4 through 8.17 | Elasticsearch 2.4 with [Delete By Query Plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/2.4/plugins-delete-by-query.html) installed |

View file

@ -46,7 +46,7 @@ module API
find_params.fetch(:all_available, current_user&.can_read_all_resources?)
groups = GroupsFinder.new(current_user, find_params).execute
groups = groups.search(params[:search]) if params[:search].present?
groups = groups.search(params[:search], include_parents: true) if params[:search].present?
groups = groups.where.not(id: params[:skip_groups]) if params[:skip_groups].present?
order_options = { params[:order_by] => params[:sort] }
order_options["id"] ||= "asc"

View file

@ -64,11 +64,17 @@ module QA
end
def has_assignee?(username)
page.within(element_selector_css(:assignee_block)) do
within_element(:assignee_block) do
has_text?(username)
end
end
def has_no_assignee_named?(username)
within_element(:assignee_block) do
has_no_text?(username)
end
end
def has_avatar_image_count?(count)
wait_assignees_block_finish_loading do
all_elements(:avatar_image, count: count)

View file

@ -57,6 +57,21 @@ module QA
hash[:weight] = @weight if @weight
end
end
def api_put_path
"/projects/#{project.id}/issues/#{iid}"
end
def set_issue_assignees(assignee_ids:)
put_body = { assignee_ids: assignee_ids }
response = put Runtime::API::Request.new(api_client, api_put_path).url, put_body
unless response.code == HTTP_STATUS_OK
raise ResourceUpdateFailedError, "Could not update issue assignees to #{assignee_ids}. Request returned (#{response.code}): `#{response}`."
end
QA::Runtime::Logger.debug("Successfully updated issue assignees to #{assignee_ids}")
end
end
end
end

View file

@ -0,0 +1,53 @@
# frozen_string_literal: true
module QA
RSpec.describe 'Plan', :requires_admin, :actioncable, :orchestrated do
describe 'Assignees' do
let(:user1) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
let(:user2) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-to-test-assignees'
end
end
before do
Runtime::Feature.enable('real_time_issue_sidebar', project: project)
Runtime::Feature.enable('broadcast_issue_updates', project: project)
Flow::Login.sign_in
project.add_member(user1)
project.add_member(user2)
end
after do
Runtime::Feature.disable('real_time_issue_sidebar', project: project)
Runtime::Feature.disable('broadcast_issue_updates', project: project)
end
it 'update without refresh', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1048' do
issue = Resource::Issue.fabricate_via_api! do |issue|
issue.project = project
issue.assignee_ids = [user1.id]
end
issue.visit!
Page::Project::Issue::Show.perform do |show|
expect(show).to have_assignee(user1.name)
issue.set_issue_assignees(assignee_ids: [user2.id])
expect(show).to have_assignee(user2.name)
expect(show).to have_no_assignee_named(user1.name)
issue.set_issue_assignees(assignee_ids: [])
expect(show).to have_no_assignee_named(user1.name)
expect(show).to have_no_assignee_named(user2.name)
end
end
end
end
end

View file

@ -1,64 +0,0 @@
import initSourcegraph from '~/sourcegraph';
const TEST_SOURCEGRAPH_URL = 'https://sourcegraph.test:9000';
const TEST_GITLAB_URL = 'https://gitlab.example.com/test';
const TEST_ASSET_HOST = 'https://gitlab-assets.example.com/';
describe('~/sourcegraph/index', () => {
let origGon;
beforeEach(() => {
origGon = window.gon;
window.gon = {
sourcegraph: {},
gitlab_url: TEST_GITLAB_URL,
};
});
afterEach(() => {
document.head.innerHTML = '';
document.body.innerHTML = '';
window.gon = origGon;
});
const findScript = () => document.querySelector('script');
it('with no sourcegraph url, does nothing', () => {
initSourcegraph();
expect(findScript()).toBeNull();
});
describe.each`
assetHost | assetsUrl | scriptPath
${null} | ${`${TEST_GITLAB_URL}/assets/webpack/sourcegraph/`} | ${`${TEST_GITLAB_URL}/assets/webpack/sourcegraph/scripts/integration.bundle.js`}
${TEST_ASSET_HOST} | ${`${TEST_ASSET_HOST}assets/webpack/sourcegraph/`} | ${`${TEST_ASSET_HOST}assets/webpack/sourcegraph/scripts/integration.bundle.js`}
`('loads sourcegraph (assetHost=$assetHost)', ({ assetHost, assetsUrl, scriptPath }) => {
beforeEach(() => {
Object.assign(window.gon, {
sourcegraph: {
url: TEST_SOURCEGRAPH_URL,
},
asset_host: assetHost,
});
initSourcegraph();
});
it('should add sourcegraph config constants to window', () => {
expect(window).toMatchObject({
SOURCEGRAPH_ASSETS_URL: assetsUrl,
SOURCEGRAPH_URL: TEST_SOURCEGRAPH_URL,
SOURCEGRAPH_INTEGRATION: 'gitlab-integration',
});
});
it('should add script tag', () => {
expect(findScript()).toMatchObject({
src: scriptPath,
defer: true,
type: 'application/javascript',
});
});
});
});

View file

@ -147,7 +147,7 @@ RSpec.describe Namespace do
end
describe '.search' do
let(:namespace) { create(:namespace) }
let_it_be(:namespace) { create(:namespace) }
it 'returns namespaces with a matching name' do
expect(described_class.search(namespace.name)).to eq([namespace])
@ -172,6 +172,18 @@ RSpec.describe Namespace do
it 'returns namespaces with a matching path regardless of the casing' do
expect(described_class.search(namespace.path.upcase)).to eq([namespace])
end
it 'returns namespaces with a matching route path' do
expect(described_class.search(namespace.route.path, include_parents: true)).to eq([namespace])
end
it 'returns namespaces with a partially matching route path' do
expect(described_class.search(namespace.route.path[0..2], include_parents: true)).to eq([namespace])
end
it 'returns namespaces with a matching route path regardless of the casing' do
expect(described_class.search(namespace.route.path.upcase, include_parents: true)).to eq([namespace])
end
end
describe '.with_statistics' do