Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2024-04-18 12:15:12 +00:00
parent 00c41e961a
commit 311e3902e9
25 changed files with 71 additions and 465 deletions

View File

@ -251,6 +251,7 @@ graphql-schema-dump:
.vue3:
variables:
VUE_VERSION: 3
NODE_OPTIONS: --max-old-space-size=7680
allow_failure: true
.jest-base:

View File

@ -3268,7 +3268,7 @@
when: never
- <<: *if-merge-request-labels-pipeline-expedite
when: never
- !reference [".releases:rules:canonical-dot-com-gitlab-stable-branch-only-setup-test-env", rules]
- !reference [".releases:rules:canonical-dot-com-gitlab-stable-branch-only", rules]
###################
# Benchmark rules #

View File

@ -75,7 +75,7 @@ include:
- echo -e "\e[0Ksection_start:`date +%s`:install_gems[collapsed=true]\r\e[0KInstall gems"
- source scripts/utils.sh
- source scripts/rspec_helpers.sh
- cd qa && bundle config set --local without 'development' && bundle install
- cd qa && bundle install
- echo -e "\e[0Ksection_end:`date +%s`:install_gems\r\e[0K"
script:
- export QA_COMMAND="bundle exec bin/qa ${QA_SCENARIO:=Test::Instance::All} $GDK_URL $GITLAB_QA_OPTS -- $QA_TESTS --order random --force-color --format documentation --format QA::Support::JsonFormatter --out tmp/rspec-${CI_JOB_ID}-\${QA_RSPEC_RETRIED:-false}.json"

View File

@ -1223,7 +1223,6 @@ Gitlab/NamespacedClass:
- 'lib/gitlab/workhorse.rb'
- 'lib/gitlab/zoom_link_extractor.rb'
- 'lib/tasks/gitlab/seed/group_seed.rake'
- 'lib/tasks/import.rake'
- 'lib/tasks/tokens.rake'
- 'lib/uploaded_file.rb'
- 'lib/version_check.rb'

View File

@ -2702,7 +2702,6 @@ Layout/LineLength:
- 'lib/tasks/gitlab/usage_data.rake'
- 'lib/tasks/gitlab/user_management.rake'
- 'lib/tasks/gitlab/workhorse.rake'
- 'lib/tasks/import.rake'
- 'lib/tasks/migrate/schema_check.rake'
- 'lib/tasks/tanuki_emoji.rake'
- 'lib/tasks/test.rake'

View File

@ -3407,7 +3407,6 @@ RSpec/FeatureCategory:
- 'spec/lib/gitlab/github_import/representation/to_hash_spec.rb'
- 'spec/lib/gitlab/github_import/representation/user_spec.rb'
- 'spec/lib/gitlab/github_import/representation_spec.rb'
- 'spec/lib/gitlab/github_import/sequential_importer_spec.rb'
- 'spec/lib/gitlab/github_import/settings_spec.rb'
- 'spec/lib/gitlab/github_import/single_endpoint_notes_importing_spec.rb'
- 'spec/lib/gitlab/github_import/user_finder_spec.rb'

View File

@ -533,7 +533,6 @@ RSpec/VerifiedDoubles:
- 'spec/lib/gitlab/github_import/parallel_scheduling_spec.rb'
- 'spec/lib/gitlab/github_import/representation/diff_note_spec.rb'
- 'spec/lib/gitlab/github_import/representation/to_hash_spec.rb'
- 'spec/lib/gitlab/github_import/sequential_importer_spec.rb'
- 'spec/lib/gitlab/github_import/user_finder_spec.rb'
- 'spec/lib/gitlab/github_import_spec.rb'
- 'spec/lib/gitlab/gon_helper_spec.rb'

View File

@ -1 +1 @@
0f9df77f1f480d5f4087cc9400c13dcbab2e174e
68c90c5cfa83c24cd706a206d13ff1e5be1c4f44

View File

@ -21,3 +21,5 @@ Knapsack.load_tasks if defined?(Knapsack)
require 'gitlab-dangerfiles'
Gitlab::Dangerfiles.load_tasks
require 'rainbow/ext/string'

View File

@ -0,0 +1,10 @@
---
name: selective_code_owner_removals_updated
description: Event triggered when selective code owner removal is updated
introduced_by_issue: https://gitlab.com/gitlab-org/gitlab/-/issues/327562
introduced_by_mr: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/148743
feature_category: code_review_workflow
milestone: '17.0'
saved_to_database: true
streamed: true
scope: [Project]

View File

@ -1,8 +0,0 @@
---
name: create_vulnerability_jira_issue_via_graphql
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60593
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/329780
milestone: '13.12'
type: development
group: group::threat insights
default_enabled: true

View File

@ -0,0 +1,18 @@
- title: "Project page in group settings is deprecated"
announcement_milestone: "17.0"
end_of_support_milestone: "17.9"
removal_milestone: "18.0"
breaking_change: false
reporter: lohrc
stage: data_stores
issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/443347
impact: [low]
scope: [group]
tiers: [core, premium, ultimate]
body: | # (required) Don't change this line.
Group owners can access a project page in the group settings that lists the projects the group contains, with options to create, edit or delete a project, as well as a link to the Members page for each project.
All of this functionality is available on the group overview page and the respective Member pages of the projects.
Due to low usage of the project page in the group settings and its limited accessibility, this page will be deprecated.
This change affects only the user interface. The underlying API will remain available, so project creation, edits, and deletions can still be performed using the [Projects API](https://docs.gitlab.com/ee/api/projects.html).
In 17.9, we will implement a redirect to the group overview page from this page.
The project page will be removed entirely from the group settings in 18.0.

View File

@ -108,6 +108,7 @@ Audit event types belong to the following product categories.
| [`project_merge_requests_template_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/84624) | Whenever a MR template is updated for a project, this audit event is created| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [15.0](https://gitlab.com/gitlab-org/gitlab/-/issues/355805) | Project |
| [`project_remove_source_branch_after_merge_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/83922) | Create this audit event whenever a project has its setting to remove branches after merges modified| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [14.10](https://gitlab.com/gitlab-org/gitlab/-/issues/301124) | Project |
| [`project_reset_approvals_on_push_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66234) | Create this audit event whenever a project has its setting on whether approvals are reset on a push is updated| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [14.2](https://gitlab.com/gitlab-org/gitlab/-/issues/336211) | Project |
| [`selective_code_owner_removals_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/148743) | Event triggered when selective code owner removal is updated| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [17.0](https://gitlab.com/gitlab-org/gitlab/-/issues/327562) | Project |
### Code suggestions

View File

@ -62,7 +62,6 @@ Some of these services have their own environment variables to override the log
| GitLab Cleanup | `INFO` | `DEBUG` |
| GitLab Doctor | `INFO` | `VERBOSE` |
| GitLab Export | `INFO` | `EXPORT_DEBUG` |
| GitLab Geo | `INFO` | |
| GitLab Import | `INFO` | `IMPORT_DEBUG` |
| GitLab QA Runtime | `INFO` | `QA_LOG_LEVEL` |
| Google APIs | `INFO` | |

View File

@ -4,7 +4,7 @@ group: Distribution
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
---
# GitHub import Rake task (deprecated)
# GitHub import Rake task (removed)
DETAILS:
**Tier:** Free, Premium, Ultimate
@ -13,55 +13,4 @@ DETAILS:
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/390690) in GitLab 15.9, Rake task no longer automatically creates namespaces or groups that don't exist.
> - Requirement for Maintainer role instead of Developer role introduced in GitLab 16.0 and backported to GitLab 15.11.1 and GitLab 15.10.5.
WARNING:
This feature was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/428225) in GitLab 16.6 and is planned for
removal in GitLab 17.0. Use the [GitHub import feature](../../user/project/import/github.md) instead.
To retrieve and import GitHub repositories, you need a [GitHub personal access token](https://github.com/settings/tokens).
A username should be passed as the second argument to the Rake task,
which becomes the owner of the project. You can resume an import
with the same command.
Bear in mind that the syntax is very specific. Remove any spaces in the argument block and
before/after the brackets. Also, some shells (for example, Zsh) can interpret the open/close brackets
(`[]`) separately. You may want to either escape the brackets or use double quotes.
You can only import repositories that are in the namespace of the owner of the GitHub personal access token being used to import. For more information, see
[issue 424105](https://gitlab.com/gitlab-org/gitlab/-/issues/424105).
Prerequisites:
- At least the Maintainer role on the destination group to import to.
## Rate limit
If the GitHub [rate limit](https://docs.github.com/en/rest/rate-limit) is reached while
importing, the importing process waits (`sleep()`) until it can continue importing.
## Importing multiple projects
To import a project from the list of your GitHub projects available:
```shell
# Omnibus installations
sudo gitlab-rake "import:github[access_token,root,foo/bar]"
# Installations from source
bundle exec rake "import:github[access_token,root,foo/bar]" RAILS_ENV=production
```
In this case, `access_token` is your GitHub personal access token, `root`
is your GitLab username, and `foo/bar` is the new GitLab namespace/project
created from your GitHub project. Subgroups are also possible: `foo/foo/bar`.
## Importing a single project
To import a specific GitHub project (named `foo/github_repo` here):
```shell
# Omnibus installations
sudo gitlab-rake "import:github[access_token,root,foo/bar,foo/github_repo]"
# Installations from source
bundle exec rake "import:github[access_token,root,foo/bar,foo/github_repo]" RAILS_ENV=production
```
This feature was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/134296) in GitLab 16.6 and [removed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/147182) in GitLab 17.0. Use the [GitHub import feature](../../user/project/import/github.md) instead.

View File

@ -1,5 +1,5 @@
---
status: ongoing
status: implemented
creation-date: "2023-09-28"
authors: [ "@mkaeppler" ]
coach: "@ayufan"

View File

@ -231,6 +231,26 @@ Offset-based pagination for the [List registry repository tags](https://docs.git
</div>
<div class="deprecation " data-milestone="18.0">
### Project page in group settings is deprecated
<div class="deprecation-notes">
- Announced in GitLab <span class="milestone">17.0</span>
- End of Support in GitLab <span class="milestone">17.9</span>
- Removal in GitLab <span class="milestone">18.0</span>
- To discuss this change or learn more, see the [deprecation issue](https://gitlab.com/gitlab-org/gitlab/-/issues/443347).
</div>
Group owners can access a project page in the group settings that lists the projects the group contains, with options to create, edit or delete a project, as well as a link to the Members page for each project.
All of this functionality is available on the group overview page and the respective Member pages of the projects.
Due to low usage of the project page in the group settings and its limited accessibility, this page will be deprecated.
This change affects only the user interface. The underlying API will remain available, so project creation, edits, and deletions can still be performed using the [Projects API](https://docs.gitlab.com/ee/api/projects.html).
In 17.9, we will implement a redirect to the group overview page from this page.
The project page will be removed entirely from the group settings in 18.0.
</div>
<div class="deprecation breaking-change" data-milestone="18.0">
### Registration tokens and server-side runner arguments in `POST /api/v4/runners` endpoint

View File

@ -1,74 +0,0 @@
# frozen_string_literal: true
module Gitlab
module GithubImport
# The SequentialImporter imports a GitHub project in a single thread,
# without using Sidekiq. This makes it useful for testing purposes as well
# as Rake tasks, but it should be avoided for anything else in favour of the
# parallel importer.
class SequentialImporter
attr_reader :project, :client
SEQUENTIAL_IMPORTERS = [
Importer::LabelsImporter,
Importer::MilestonesImporter,
Importer::ReleasesImporter
].freeze
PARALLEL_IMPORTERS = [
Importer::ProtectedBranchesImporter,
Importer::PullRequestsImporter,
Importer::IssuesImporter,
Importer::DiffNotesImporter,
Importer::NotesImporter,
Importer::LfsObjectsImporter
].freeze
# project - The project to import the data into.
# token - The token to use for the GitHub API.
# host - The GitHub hostname. If nil, github.com will be used.
def initialize(project, token: nil, host: nil)
@project = project
@client = GithubImport
.new_client_for(project, token: token, host: host, parallel: false)
end
def execute
metrics.track_start_import
begin
Importer::RepositoryImporter.new(project, client).execute
SEQUENTIAL_IMPORTERS.each do |klass|
klass.new(project, client).execute
end
rescue StandardError => e
Gitlab::Import::ImportFailureService.track(
project_id: project.id,
error_source: self.class.name,
exception: e,
fail_import: true,
metrics: true
)
raise(e)
end
PARALLEL_IMPORTERS.each do |klass|
klass.new(project, client, parallel: false).execute
end
metrics.track_finished_import
true
end
private
def metrics
@metrics ||= Gitlab::Import::Metrics.new(:github_importer, project)
end
end
end
end

View File

@ -1,133 +0,0 @@
# frozen_string_literal: true
class GithubImport
def self.run!(...)
new(...).run!
end
def initialize(token, gitlab_username, project_path, extras)
@options = { token: token }
@project_path = project_path
@current_user = UserFinder.new(gitlab_username).find_by_username
raise "GitLab user #{gitlab_username} not found. Please specify a valid username." unless @current_user
@github_repo = extras.empty? ? nil : extras.first
end
def run!
@repo = GithubRepos
.new(@options[:token], @current_user, @github_repo)
.choose_one!
raise 'No repo found!' unless @repo
show_warning!
@project = Project.find_by_full_path(@project_path) || new_project
import!
end
private
def show_warning!
puts "This will import GitHub #{@repo[:full_name].bright} into GitLab #{@project_path.bright} as #{@current_user.name}"
puts 'Permission checks are ignored. Press any key to continue.'.color(:red)
$stdin.getch
puts 'Starting the import (this could take a while)'.color(:green)
end
def import!
@project.import_state.force_start
timings = Benchmark.measure do
Gitlab::GithubImport::SequentialImporter
.new(@project, token: @options[:token])
.execute
end
@project.after_import
puts "Import finished. Timings: #{timings}".color(:green)
end
def new_project
namespace_path, _sep, project_name = @project_path.rpartition('/')
target_namespace = Namespace.find_by_full_path(namespace_path)
raise s_('GithubImport|Namespace or group to import repository into does not exist.') unless target_namespace
Project.transaction do
project = Projects::CreateService.new(
@current_user,
name: project_name,
path: project_name,
description: @repo[:description],
namespace_id: target_namespace.id,
visibility_level: visibility_level,
skip_wiki: @repo[:has_wiki]
).execute
project.update!(
import_type: 'github',
import_source: @repo[:full_name],
import_url: @repo[:clone_url].sub('://', "://#{@options[:token]}@")
)
project
end
end
def visibility_level
@repo[:private] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::CurrentSettings.current_application_settings.default_project_visibility
end
end
class GithubRepos
def initialize(token, current_user, github_repo)
@client = Gitlab::GithubImport::Client.new(token)
@client.octokit.auto_paginate = true
@current_user = current_user
@github_repo = github_repo
end
def choose_one!
return found_github_repo if @github_repo
repos.each do |repo|
print "ID: #{repo[:id].to_s.bright}".color(:green)
print "\tName: #{repo[:full_name]}\n".color(:green)
end
print 'ID? '.bright
repos.find { |repo| repo[:id] == repo_id }
end
def found_github_repo
repos.find { |repo| repo[:full_name] == @github_repo }
end
def repo_id
@repo_id ||= $stdin.gets.chomp.to_i
end
def repos
@repos ||= @client.repos
end
end
namespace :import do
require 'benchmark'
require 'rainbow/ext/string'
desc 'GitLab | Import | Import a GitHub project - Example: import:github[ToKeN,root,root/blah,my/github_repo] (optional my/github_repo)'
task :github, [:token, :gitlab_username, :project_path] => :environment do |_t, args|
abort 'Project path must be: namespace(s)/project_name'.color(:red) unless args.project_path.include?('/')
GithubImport.run!(args.token, args.gitlab_username, args.project_path, args.extras)
end
end

View File

@ -259,12 +259,6 @@ tests = [
]
},
{
explanation: 'Map FOSS rake tasks',
changed_file: 'lib/tasks/import.rake',
expected: ['spec/tasks/import_rake_spec.rb']
},
{
explanation: 'Map EE rake tasks',
changed_file: 'ee/lib/tasks/geo.rake',

View File

@ -2556,9 +2556,13 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen
end
it 'can still access objects in the object pool' do
object_pool.link(repository)
new_commit_id = object_pool.repository.commit_files(
project.owner,
# Create a commit into a separate repository and fetch it into the object pool.
# Writing directly to an object pool fails as we don't support them in the
# authorization checks. Gitaly's pre-receive hook fails as a gl_repository is
# not set object pools.
source_project = create(:project, :repository)
new_commit_id = source_project.repository.commit_files(
source_project.owner,
branch_name: object_pool.repository.root_ref,
message: 'Add a file',
actions: [{
@ -2566,7 +2570,12 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen
file_path: 'a.file',
content: 'This is a file.'
}]
).newrev
)
# Fetch the new object into the object pool
Gitlab::GitalyClient::ObjectPoolService.new(object_pool).fetch(source_project.repository)
object_pool.link(repository)
expect(repository.commit(new_commit_id).id).to eq(new_commit_id)

View File

@ -1,64 +0,0 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::GithubImport::SequentialImporter do
describe '#execute' do
let_it_be(:project) do
create(:project, import_url: 'http://t0ken@github.another-domain.com/repo-org/repo.git', import_type: 'github')
end
subject(:importer) { described_class.new(project, token: 'foo') }
it 'imports a project in sequence' do
expect_next_instance_of(Gitlab::Import::Metrics) do |instance|
expect(instance).to receive(:track_start_import)
expect(instance).to receive(:track_finished_import)
end
expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
expect(instance).to receive(:execute)
end
described_class::SEQUENTIAL_IMPORTERS.each do |klass|
instance = double(:instance)
expect(klass).to receive(:new)
.with(project, importer.client)
.and_return(instance)
expect(instance).to receive(:execute)
end
described_class::PARALLEL_IMPORTERS.each do |klass|
instance = double(:instance)
expect(klass).to receive(:new)
.with(project, importer.client, parallel: false)
.and_return(instance)
expect(instance).to receive(:execute)
end
expect(importer.execute).to eq(true)
end
it 'raises an error' do
exception = StandardError.new('_some_error_')
expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |importer|
expect(importer).to receive(:execute).and_raise(exception)
end
expect(Gitlab::Import::ImportFailureService).to receive(:track)
.with(
project_id: project.id,
exception: exception,
error_source: described_class.name,
fail_import: true,
metrics: true
).and_call_original
expect { importer.execute }.to raise_error(StandardError)
end
end
end

View File

@ -977,7 +977,6 @@
- spec/services/work_items/update_service_spec.rb
- spec/tasks/gitlab/backup_rake_spec.rb
- spec/tasks/gitlab/check_rake_spec.rb
- spec/tasks/import_rake_spec.rb
- spec/views/layouts/header/_new_dropdown.haml_spec.rb
- spec/views/layouts/profile.html.haml_spec.rb
- spec/views/profiles/preferences/show.html.haml_spec.rb

View File

@ -6020,7 +6020,6 @@
- './spec/lib/gitlab/github_import/representation_spec.rb'
- './spec/lib/gitlab/github_import/representation/to_hash_spec.rb'
- './spec/lib/gitlab/github_import/representation/user_spec.rb'
- './spec/lib/gitlab/github_import/sequential_importer_spec.rb'
- './spec/lib/gitlab/github_import/single_endpoint_notes_importing_spec.rb'
- './spec/lib/gitlab/github_import_spec.rb'
- './spec/lib/gitlab/github_import/user_finder_spec.rb'

View File

@ -1,112 +0,0 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'import:github rake tasks', feature_category: :importers do
before do
Rake.application.rake_require 'tasks/import'
end
describe ':import' do
let(:user) { create(:user) }
let(:user_name) { user.username }
let(:github_repo) { 'github_user/repo' }
let(:target_namespace) { user.namespace_path }
let(:project_path) { "#{target_namespace}/project_name" }
before do
allow($stdin).to receive(:getch)
stub_request(:get, 'https://api.github.com/user/repos?per_page=100')
.to_return(
status: 200,
body: [{ id: 1, full_name: 'github_user/repo', clone_url: 'https://github.com/user/repo.git' }].to_json,
headers: { 'Content-Type' => 'application/json' }
)
end
context 'when importing a single project' do
subject(:import_task) { run_rake_task('import:github', 'token', user_name, project_path, github_repo) }
context 'when all inputs are correct' do
it 'imports a repository' do
expect_next_instance_of(Gitlab::GithubImport::SequentialImporter) do |importer|
expect(importer).to receive(:execute)
end
expect_next_instance_of(Project) do |project|
expect(project).to receive(:after_import)
end
import_task
end
end
context 'when project path is invalid' do
let(:project_path) { target_namespace }
it 'aborts with an error' do
expect { import_task }.to raise_error(SystemExit, 'Project path must be: namespace(s)/project_name')
end
end
context 'when user is not found' do
let(:user_name) { 'unknown_user' }
it 'aborts with an error' do
expect { import_task }.to raise_error("GitLab user #{user_name} not found. Please specify a valid username.")
end
end
context 'when github repo is not found' do
let(:github_repo) { 'github_user/unknown_repo' }
it 'aborts with an error' do
expect { import_task }.to raise_error('No repo found!')
end
end
context 'when namespace to import repo into does not exists' do
let(:target_namespace) { 'unknown_namespace_path' }
it 'aborts with an error' do
expect do
import_task
end.to raise_error(s_('GithubImport|Namespace or group to import repository into does not exist.'))
end
end
end
context 'when importing multiple projects' do
subject(:import_task) { run_rake_task('import:github', 'token', user_name, project_path) }
context 'when user enters github repo id that exists' do
before do
allow($stdin).to receive(:gets).and_return("1\n")
end
it 'imports a repository' do
expect_next_instance_of(Gitlab::GithubImport::SequentialImporter) do |importer|
expect(importer).to receive(:execute)
end
expect_next_instance_of(Project) do |project|
expect(project).to receive(:after_import)
end
import_task
end
end
context 'when user enters github repo id that does not exists' do
before do
allow($stdin).to receive(:gets).and_return("2\n")
end
it 'aborts with an error' do
expect { import_task }.to raise_error('No repo found!')
end
end
end
end
end