From bd1e3cbdeb153c9bf73abe3ba7bf3ecb7d203719 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 8 Jun 2021 03:10:25 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- app/controllers/projects_controller.rb | 1 + app/services/projects/create_service.rb | 10 +++++++ app/services/projects/update_service.rb | 9 ++++++ .../projects/settings/_general.html.haml | 4 +-- config/gitlab.yml.example | 3 ++ config/initializers/1_settings.rb | 2 ++ db/fixtures/production/002_admin.rb | 6 +++- doc/api/projects.md | 9 ++++-- doc/ci/jobs/job_control.md | 3 ++ lib/api/helpers/projects_helpers.rb | 4 ++- locale/gitlab.pot | 6 ++-- spec/requests/api/projects_spec.rb | 30 ++++++++++++++++++- spec/services/projects/create_service_spec.rb | 28 +++++++++++++++++ spec/services/projects/update_service_spec.rb | 25 ++++++++++++++++ 14 files changed, 129 insertions(+), 11 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 62af141fbc5..b37d5466757 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -436,6 +436,7 @@ class ProjectsController < Projects::ApplicationController :request_access_enabled, :runners_token, :tag_list, + :topics, :visibility_level, :template_name, :template_project_id, diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 97ea7d87545..8beb34a4626 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -11,6 +11,8 @@ module Projects @initialize_with_readme = Gitlab::Utils.to_boolean(@params.delete(:initialize_with_readme)) @import_data = @params.delete(:import_data) @relations_block = @params.delete(:relations_block) + + build_topics end def execute @@ -261,6 +263,14 @@ module Projects .new(current_user, @project, project_params: { import_data: @import_data }) .level_restricted? end + + def build_topics + topics = params.delete(:topics) + tag_list = params.delete(:tag_list) + topic_list = topics || tag_list + + params[:topic_list] ||= topic_list if topic_list + end end end diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb index 541b333aae3..4351a66351d 100644 --- a/app/services/projects/update_service.rb +++ b/app/services/projects/update_service.rb @@ -8,6 +8,7 @@ module Projects ValidationError = Class.new(StandardError) def execute + build_topics remove_unallowed_params validate! @@ -167,6 +168,14 @@ module Projects project.repository_storage != new_repository_storage && can?(current_user, :change_repository_storage, project) end + + def build_topics + topics = params.delete(:topics) + tag_list = params.delete(:tag_list) + topic_list = topics || tag_list + + params[:topic_list] ||= topic_list if topic_list + end end end diff --git a/app/views/projects/settings/_general.html.haml b/app/views/projects/settings/_general.html.haml index 845fb299b74..0891e3e0526 100644 --- a/app/views/projects/settings/_general.html.haml +++ b/app/views/projects/settings/_general.html.haml @@ -15,8 +15,8 @@ .row .form-group.col-md-9 - = f.label :tag_list, _('Topics (optional)'), class: 'label-bold' - = f.text_field :tag_list, value: @project.tag_list.join(', '), maxlength: 2000, class: "form-control gl-form-input" + = f.label :topics, _('Topics (optional)'), class: 'label-bold' + = f.text_field :topics, value: @project.topic_list.join(', '), maxlength: 2000, class: "form-control gl-form-input" %p.form-text.text-muted= _('Separate topics with commas.') = render_if_exists 'compliance_management/compliance_framework/project_settings', f: f diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 57694da4dfa..557fbd0a107 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -170,6 +170,9 @@ production: &base ## Application settings cache expiry in seconds (default: 60) # application_settings_cache_seconds: 60 + ## Print initial root password to stdout during initialization (default: true) + # display_initial_root_password: true + ## Reply by email # Allow users to comment on issues and merge requests by replying to notification emails. # For documentation on how to set this up, see http://doc.gitlab.com/ce/administration/reply_by_email.html diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index c00d0c04e5f..a9f5c569823 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -216,6 +216,8 @@ Settings.gitlab['impersonation_enabled'] ||= true if Settings.gitlab['impersonat Settings.gitlab['usage_ping_enabled'] = true if Settings.gitlab['usage_ping_enabled'].nil? Settings.gitlab['max_request_duration_seconds'] ||= 57 +Settings.gitlab['display_initial_root_password'] = true if Settings.gitlab['display_initial_root_password'].nil? + Gitlab.ee do Settings.gitlab['mirror_max_delay'] ||= 300 Settings.gitlab['mirror_max_capacity'] ||= 30 diff --git a/db/fixtures/production/002_admin.rb b/db/fixtures/production/002_admin.rb index 1c7c89f7bbd..b6a6da3a188 100644 --- a/db/fixtures/production/002_admin.rb +++ b/db/fixtures/production/002_admin.rb @@ -23,7 +23,11 @@ if user.persisted? puts "login: root".color(:green) if user_args.key?(:password) - puts "password: #{user_args[:password]}".color(:green) + if ::Settings.gitlab['display_initial_root_password'] + puts "password: #{user_args[:password]}".color(:green) + else + puts "password: *** - You opted not to display initial root password to STDOUT." + end else puts "password: You'll be prompted to create one on your first visit.".color(:green) end diff --git a/doc/api/projects.md b/doc/api/projects.md index 57c6ea9be93..15db85eb349 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -1206,9 +1206,10 @@ POST /projects | `show_default_award_emojis` | boolean | **{dotted-circle}** No | Show default award emojis. | | `snippets_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `snippets_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable snippets for this project. Use `snippets_access_level` instead. | -| `tag_list` | array | **{dotted-circle}** No | The list of tags for a project; put array of tags, that should be finally assigned to a project. | +| `tag_list` | array | **{dotted-circle}** No | _([Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 14.0)_ The list of tags for a project; put array of tags, that should be finally assigned to a project. Use `topics` instead. | | `template_name` | string | **{dotted-circle}** No | When used without `use_custom_template`, name of a [built-in project template](../user/project/working_with_projects.md#built-in-templates). When used with `use_custom_template`, name of a custom project template. | | `template_project_id` **(PREMIUM)** | integer | **{dotted-circle}** No | When used with `use_custom_template`, project ID of a custom project template. This is preferable to using `template_name` since `template_name` may be ambiguous. | +| `topics` | array | **{dotted-circle}** No | The list of topics for a project; put array of topics, that should be finally assigned to a project. _([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 14.0.)_ | | `use_custom_template` **(PREMIUM)** | boolean | **{dotted-circle}** No | Use either custom [instance](../user/admin_area/custom_project_templates.md) or [group](../user/group/custom_project_templates.md) (with `group_with_project_templates_id`) project template. | | `visibility` | string | **{dotted-circle}** No | See [project visibility level](#project-visibility-level). | | `wiki_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | @@ -1280,8 +1281,9 @@ POST /projects/user/:user_id | `snippets_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `snippets_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable snippets for this project. Use `snippets_access_level` instead. | | `suggestion_commit_message` | string | **{dotted-circle}** No | The commit message used to apply merge request [suggestions](../user/project/merge_requests/reviews/suggestions.md). | -| `tag_list` | array | **{dotted-circle}** No | The list of tags for a project; put array of tags, that should be finally assigned to a project. | +| `tag_list` | array | **{dotted-circle}** No | _([Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 14.0)_ The list of tags for a project; put array of tags, that should be finally assigned to a project. Use `topics` instead. | | `template_name` | string | **{dotted-circle}** No | When used without `use_custom_template`, name of a [built-in project template](../user/project/working_with_projects.md#built-in-templates). When used with `use_custom_template`, name of a custom project template. | +| `topics` | array | **{dotted-circle}** No | The list of topics for the project. _([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 14.0.)_ | | `use_custom_template` **(PREMIUM)** | boolean | **{dotted-circle}** No | Use either custom [instance](../user/admin_area/custom_project_templates.md) or [group](../user/group/custom_project_templates.md) (with `group_with_project_templates_id`) project template. | | `visibility` | string | **{dotted-circle}** No | See [project visibility level](#project-visibility-level). | | `wiki_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | @@ -1358,7 +1360,8 @@ PUT /projects/:id | `snippets_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `snippets_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable snippets for this project. Use `snippets_access_level` instead. | | `suggestion_commit_message` | string | **{dotted-circle}** No | The commit message used to apply merge request suggestions. | -| `tag_list` | array | **{dotted-circle}** No | The list of tags for a project; put array of tags, that should be finally assigned to a project. | +| `tag_list` | array | **{dotted-circle}** No | _([Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 14.0)_ The list of tags for a project; put array of tags, that should be finally assigned to a project. Use `topics` instead. | +| `topics` | array | **{dotted-circle}** No | The list of topics for the project. This replaces any existing topics that are already added to the project. _([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 14.0.)_ | | `visibility` | string | **{dotted-circle}** No | See [project visibility level](#project-visibility-level). | | `wiki_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `wiki_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable wiki for this project. Use `wiki_access_level` instead. | diff --git a/doc/ci/jobs/job_control.md b/doc/ci/jobs/job_control.md index 734ec4b5193..9efa63e072c 100644 --- a/doc/ci/jobs/job_control.md +++ b/doc/ci/jobs/job_control.md @@ -85,6 +85,9 @@ job1: - ($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop") && $MY_VARIABLE ``` +When multiple entries are specified in `only:variables`, the job runs when at least one of them evaluates to `true`. +You can use `&&` in a single entry when multiple conditions must be satisfied at the same time. + ### `only:changes` / `except:changes` examples You can skip a job if a change is detected in any file with a diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb index d9c0b4f67c8..e2897ba6a3c 100644 --- a/lib/api/helpers/projects_helpers.rb +++ b/lib/api/helpers/projects_helpers.rb @@ -51,7 +51,8 @@ module API optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed' optional :allow_merge_on_skipped_pipeline, type: Boolean, desc: 'Allow to merge if pipeline is skipped' optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved' - optional :tag_list, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The list of tags for a project' + optional :tag_list, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'Deprecated: Use :topics instead' + optional :topics, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The list of topics for a project' # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 optional :avatar, type: File, desc: 'Avatar image for project' # rubocop:disable Scalability/FileUploads optional :printing_merge_request_link_enabled, type: Boolean, desc: 'Show link to create/view merge request when pushing from the command line' @@ -146,6 +147,7 @@ module API :shared_runners_enabled, :snippets_access_level, :tag_list, + :topics, :visibility, :wiki_access_level, :avatar, diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 2f5215e7e0c..cc042d21e08 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -21815,9 +21815,6 @@ msgstr "" msgid "NetworkPolicies|Are you sure you want to delete this policy? This action cannot be undone." msgstr "" -msgid "NetworkPolicies|Container runtime" -msgstr "" - msgid "NetworkPolicies|Create policy" msgstr "" @@ -21869,6 +21866,9 @@ msgstr "" msgid "NetworkPolicies|Network Policy" msgstr "" +msgid "NetworkPolicies|Network policy" +msgstr "" + msgid "NetworkPolicies|Network traffic" msgstr "" diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 51b87a55b1e..96390aa576b 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -1033,7 +1033,7 @@ RSpec.describe API::Projects do expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/-/blob/master/README.md") end - it 'sets tag list to a project' do + it 'sets tag list to a project (deprecated)' do project = attributes_for(:project, tag_list: %w[tagFirst tagSecond]) post api('/projects', user), params: project @@ -1041,6 +1041,14 @@ RSpec.describe API::Projects do expect(json_response['tag_list']).to eq(%w[tagFirst tagSecond]) end + it 'sets topics to a project' do + project = attributes_for(:project, topics: %w[topic1 topics2]) + + post api('/projects', user), params: project + + expect(json_response['tag_list']).to eq(%w[topic1 topics2]) + end + it 'uploads avatar for project a project' do project = attributes_for(:project, avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif')) @@ -3012,6 +3020,26 @@ RSpec.describe API::Projects do expect(json_response['auto_devops_enabled']).to eq(false) end + + it 'updates topics using tag_list (deprecated)' do + project_param = { tag_list: 'topic1' } + + put api("/projects/#{project3.id}", user), params: project_param + + expect(response).to have_gitlab_http_status(:ok) + + expect(json_response['tag_list']).to eq(%w[topic1]) + end + + it 'updates topics' do + project_param = { topics: 'topic2' } + + put api("/projects/#{project3.id}", user), params: project_param + + expect(response).to have_gitlab_http_status(:ok) + + expect(json_response['tag_list']).to eq(%w[topic2]) + end end context 'when authenticated as project maintainer' do diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index 6c0f36ededa..753c89eb981 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -82,6 +82,34 @@ RSpec.describe Projects::CreateService, '#execute' do end end + describe 'topics' do + subject(:project) { create_project(user, opts) } + + context "with 'topics' parameter" do + let(:opts) { { topics: 'topics' } } + + it 'keeps them as specified' do + expect(project.topic_list).to eq(%w[topics]) + end + end + + context "with 'topic_list' parameter" do + let(:opts) { { topic_list: 'topic_list' } } + + it 'keeps them as specified' do + expect(project.topic_list).to eq(%w[topic_list]) + end + end + + context "with 'tag_list' parameter (deprecated)" do + let(:opts) { { tag_list: 'tag_list' } } + + it 'keeps them as specified' do + expect(project.topic_list).to eq(%w[tag_list]) + end + end + end + context 'user namespace' do it do project = create_project(user, opts) diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb index b9e909e8615..e1b22da2e61 100644 --- a/spec/services/projects/update_service_spec.rb +++ b/spec/services/projects/update_service_spec.rb @@ -587,6 +587,31 @@ RSpec.describe Projects::UpdateService do it_behaves_like 'the transfer was not scheduled' end end + + describe 'when updating topics' do + let(:project) { create(:project, topic_list: 'topic1, topic2') } + + it 'update using topics' do + result = update_project(project, user, { topics: 'topics' }) + + expect(result[:status]).to eq(:success) + expect(project.topic_list).to eq(%w[topics]) + end + + it 'update using topic_list' do + result = update_project(project, user, { topic_list: 'topic_list' }) + + expect(result[:status]).to eq(:success) + expect(project.topic_list).to eq(%w[topic_list]) + end + + it 'update using tag_list (deprecated)' do + result = update_project(project, user, { tag_list: 'tag_list' }) + + expect(result[:status]).to eq(:success) + expect(project.topic_list).to eq(%w[tag_list]) + end + end end describe '#run_auto_devops_pipeline?' do