summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-15 21:08:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-15 21:08:42 +0000
commit040d734373c9c2db3c70eb81798db038576847ca (patch)
treeb2bdeaa38a9c13a1ea7e59083755e1bf4c7e6b22
parentb302502690b2e1422a4ef6abebdcf3ff4dc88543 (diff)
downloadgitlab-ce-040d734373c9c2db3c70eb81798db038576847ca.tar.gz
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/issue_templates/Geo Replicate a new Git repository type.md2
-rw-r--r--.gitlab/issue_templates/Geo Replicate a new blob type.md2
-rw-r--r--app/controllers/projects/tags/releases_controller.rb2
-rw-r--r--app/controllers/projects/tags_controller.rb2
-rw-r--r--app/events/projects/project_path_changed_event.rb19
-rw-r--r--app/services/projects/after_rename_service.rb13
-rw-r--r--app/services/service_ping/submit_service.rb11
-rw-r--r--app/views/projects/tags/_edit_release_button.html.haml11
-rw-r--r--app/views/projects/tags/_tag.html.haml3
-rw-r--r--app/views/projects/tags/show.html.haml5
-rw-r--r--config/feature_flags/development/edit_tag_release_notes_via_release_page.yml8
-rw-r--r--doc/development/database/transaction_guidelines.md4
-rw-r--r--doc/development/service_ping/index.md7
-rw-r--r--doc/development/service_ping/metrics_dictionary.md30
-rw-r--r--doc/user/admin_area/reporting/git_abuse_rate_limit.md29
-rw-r--r--doc/user/admin_area/settings/index.md1
-rw-r--r--doc/user/application_security/container_scanning/index.md8
-rw-r--r--lib/gitlab/database.rb2
-rw-r--r--lib/gitlab/metrics/subscribers/active_record.rb2
-rw-r--r--locale/gitlab.pot6
-rw-r--r--qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb2
-rw-r--r--spec/events/projects/project_path_changed_event_spec.rb46
-rw-r--r--spec/features/projects/tags/user_edits_tags_spec.rb47
-rw-r--r--spec/features/tags/developer_updates_tag_spec.rb2
-rw-r--r--spec/services/projects/after_rename_service_spec.rb16
-rw-r--r--spec/services/service_ping/submit_service_ping_service_spec.rb26
26 files changed, 261 insertions, 45 deletions
diff --git a/.gitlab/issue_templates/Geo Replicate a new Git repository type.md b/.gitlab/issue_templates/Geo Replicate a new Git repository type.md
index a00893dd867..e1c5928b950 100644
--- a/.gitlab/issue_templates/Geo Replicate a new Git repository type.md
+++ b/.gitlab/issue_templates/Geo Replicate a new Git repository type.md
@@ -64,7 +64,7 @@ For more information, see the [Enable Geo migrations to use Migration[2.0]](http
disable_ddl_transaction!
def up
- ActiveRecord::Base.transaction do
+ ApplicationRecord.transaction do
create_table :cool_widget_registry, id: :bigserial, force: :cascade do |t|
t.bigint :cool_widget_id, null: false
t.datetime_with_timezone :created_at, null: false
diff --git a/.gitlab/issue_templates/Geo Replicate a new blob type.md b/.gitlab/issue_templates/Geo Replicate a new blob type.md
index 35978c87418..9158885262d 100644
--- a/.gitlab/issue_templates/Geo Replicate a new blob type.md
+++ b/.gitlab/issue_templates/Geo Replicate a new blob type.md
@@ -66,7 +66,7 @@ For more information, see the [Enable Geo migrations to use Migration[2.0]](http
disable_ddl_transaction!
def up
- ActiveRecord::Base.transaction do
+ ApplicationRecord.transaction do
create_table :cool_widget_registry, id: :bigserial, force: :cascade do |t|
t.bigint :cool_widget_id, null: false
t.datetime_with_timezone :created_at, null: false
diff --git a/app/controllers/projects/tags/releases_controller.rb b/app/controllers/projects/tags/releases_controller.rb
index b852673d82a..adeadf2133e 100644
--- a/app/controllers/projects/tags/releases_controller.rb
+++ b/app/controllers/projects/tags/releases_controller.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+# TODO: remove this file together with FF https://gitlab.com/gitlab-org/gitlab/-/issues/366244
+# also delete view/routes
class Projects::Tags::ReleasesController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb
index 432497850f2..847b1baca10 100644
--- a/app/controllers/projects/tags_controller.rb
+++ b/app/controllers/projects/tags_controller.rb
@@ -53,7 +53,7 @@ class Projects::TagsController < Projects::ApplicationController
return render_404 unless @tag
- @release = @project.releases.find_or_initialize_by(tag: @tag.name)
+ @release = @project.releases.find_by(tag: @tag.name)
@commit = @repository.commit(@tag.dereferenced_target)
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/events/projects/project_path_changed_event.rb b/app/events/projects/project_path_changed_event.rb
new file mode 100644
index 00000000000..965f9258d3f
--- /dev/null
+++ b/app/events/projects/project_path_changed_event.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Projects
+ class ProjectPathChangedEvent < ::Gitlab::EventStore::Event
+ def schema
+ {
+ 'type' => 'object',
+ 'properties' => {
+ 'project_id' => { 'type' => 'integer' },
+ 'namespace_id' => { 'type' => 'integer' },
+ 'root_namespace_id' => { 'type' => 'integer' },
+ 'old_path' => { 'type' => 'string' },
+ 'new_path' => { 'type' => 'string' }
+ },
+ 'required' => %w[project_id namespace_id root_namespace_id old_path new_path]
+ }
+ end
+ end
+end
diff --git a/app/services/projects/after_rename_service.rb b/app/services/projects/after_rename_service.rb
index 2ed4346e5ca..9dc957b5be2 100644
--- a/app/services/projects/after_rename_service.rb
+++ b/app/services/projects/after_rename_service.rb
@@ -46,6 +46,7 @@ module Projects
update_repository_configuration
rename_transferred_documents
log_completion
+ publish_event
end
def first_ensure_no_registry_tags_are_present
@@ -132,6 +133,18 @@ module Projects
raise RenameFailedError, error
end
+
+ def publish_event
+ event = Projects::ProjectPathChangedEvent.new(data: {
+ project_id: project.id,
+ namespace_id: project.namespace_id,
+ root_namespace_id: project.root_namespace.id,
+ old_path: full_path_before,
+ new_path: full_path_after
+ })
+
+ Gitlab::EventStore.publish(event)
+ end
end
end
diff --git a/app/services/service_ping/submit_service.rb b/app/services/service_ping/submit_service.rb
index 9d9451015e2..89cb14e6fff 100644
--- a/app/services/service_ping/submit_service.rb
+++ b/app/services/service_ping/submit_service.rb
@@ -52,13 +52,22 @@ module ServicePing
ServicePing::DevopsReport.new(response).execute
end
- submit_payload({ metadata: { metrics: metrics_collection_time(usage_data) } }, path: METADATA_PATH)
+ submit_payload(metadata(usage_data), path: METADATA_PATH)
end
private
attr_reader :payload, :skip_db_write
+ def metadata(service_ping_payload)
+ {
+ metadata: {
+ uuid: service_ping_payload[:uuid],
+ metrics: metrics_collection_time(service_ping_payload)
+ }
+ }
+ end
+
def metrics_collection_time(payload, parents = [])
return [] unless payload.is_a?(Hash)
diff --git a/app/views/projects/tags/_edit_release_button.html.haml b/app/views/projects/tags/_edit_release_button.html.haml
new file mode 100644
index 00000000000..5bdf1c7896c
--- /dev/null
+++ b/app/views/projects/tags/_edit_release_button.html.haml
@@ -0,0 +1,11 @@
+- if Feature.enabled?(:edit_tag_release_notes_via_release_page, project)
+ - release_btn_text = s_('TagsPage|Create release')
+ - release_btn_path = new_project_release_path(project, tag_name: tag.name)
+ - if release
+ - release_btn_text = s_('TagsPage|Edit release')
+ - release_btn_path = edit_project_release_path(project, release)
+ = link_to release_btn_path, class: 'btn gl-button btn-default btn-icon btn-edit has-tooltip', title: release_btn_text, data: { container: "body" } do
+ = sprite_icon('pencil', css_class: 'gl-icon')
+- else
+ = link_to edit_project_tag_release_path(project, tag.name), class: 'btn gl-button btn-default btn-icon btn-edit has-tooltip', title: s_('TagsPage|Edit release notes'), data: { container: "body" } do
+ = sprite_icon('pencil', css_class: 'gl-icon')
diff --git a/app/views/projects/tags/_tag.html.haml b/app/views/projects/tags/_tag.html.haml
index 7654150509e..258f662420b 100644
--- a/app/views/projects/tags/_tag.html.haml
+++ b/app/views/projects/tags/_tag.html.haml
@@ -40,6 +40,5 @@
= render 'projects/buttons/download', project: @project, ref: tag.name, pipeline: @tags_pipelines[tag.name]
- if can?(current_user, :admin_tag, @project)
- = link_to edit_project_tag_release_path(@project, tag.name), class: 'btn gl-button btn-default btn-icon btn-edit has-tooltip', title: s_('TagsPage|Edit release notes'), data: { container: "body" } do
- = sprite_icon('pencil', css_class: 'gl-icon')
+ = render 'edit_release_button', tag: tag, project: @project, release: release
= render 'projects/buttons/remove_tag', project: @project, tag: tag
diff --git a/app/views/projects/tags/show.html.haml b/app/views/projects/tags/show.html.haml
index 2a68ad37c1e..24da8e2db87 100644
--- a/app/views/projects/tags/show.html.haml
+++ b/app/views/projects/tags/show.html.haml
@@ -41,8 +41,7 @@
- if @tag.has_signature?
= render partial: 'projects/commit/signature', object: @tag.signature
- if can?(current_user, :admin_tag, @project)
- = link_to edit_project_tag_release_path(@project, @tag.name), class: 'btn btn-icon btn-edit gl-button btn-default controls-item has-tooltip', title: s_('TagsPage|Edit release notes') do
- = sprite_icon("pencil", css_class: 'gl-icon')
+ = render 'edit_release_button', tag: @tag, project: @project, release: @release
= link_to project_tree_path(@project, @tag.name), class: 'btn btn-icon gl-button btn-default controls-item has-tooltip', title: s_('TagsPage|Browse files') do
= sprite_icon('folder-open', css_class: 'gl-icon')
= link_to project_commits_path(@project, @tag.name), class: 'btn btn-icon gl-button btn-default controls-item has-tooltip', title: s_('TagsPage|Browse commits') do
@@ -58,7 +57,7 @@
= strip_signature(@tag.message)
.gl-mb-3.gl-mt-3
- - if @release.description.present?
+ - if @release&.description.present?
.description.md{ data: { qa_selector: 'tag_release_notes_content' } }
= markdown_field(@release, :description)
- else
diff --git a/config/feature_flags/development/edit_tag_release_notes_via_release_page.yml b/config/feature_flags/development/edit_tag_release_notes_via_release_page.yml
new file mode 100644
index 00000000000..1f67eafc06b
--- /dev/null
+++ b/config/feature_flags/development/edit_tag_release_notes_via_release_page.yml
@@ -0,0 +1,8 @@
+---
+name: edit_tag_release_notes_via_release_page
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88832
+rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/366244
+milestone: '15.2'
+type: development
+group: group::release
+default_enabled: false
diff --git a/doc/development/database/transaction_guidelines.md b/doc/development/database/transaction_guidelines.md
index d96d11f05a5..255de19a420 100644
--- a/doc/development/database/transaction_guidelines.md
+++ b/doc/development/database/transaction_guidelines.md
@@ -132,12 +132,12 @@ end
build_1 = Ci::Build.find(1)
build_2 = Ci::Build.find(2)
-ActiveRecord::Base.transaction do
+ApplicationRecord.transaction do
build_1.touch
build_2.touch
end
```
-The `ActiveRecord::Base` class uses a different database connection than the `Ci::Build` records.
+The `ApplicationRecord` class uses a different database connection than the `Ci::Build` records.
The two statements in the transaction block are not part of the transaction and are
rolled back in case something goes wrong. They act as 3rd part calls.
diff --git a/doc/development/service_ping/index.md b/doc/development/service_ping/index.md
index 3e54aad11cc..cd8af3e9152 100644
--- a/doc/development/service_ping/index.md
+++ b/doc/development/service_ping/index.md
@@ -117,8 +117,11 @@ sequenceDiagram
> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/295289) in GitLab 15.2. [Feature flag `measure_service_ping_metric_collection`](https://gitlab.com/gitlab-org/gitlab/-/issues/358128) removed.
```ruby
- {"metadata"=>
- {"metrics"=>
+ {
+ "metadata"=>
+ {
+ "uuid"=>"0000000-0000-0000-0000-000000000000",
+ "metrics"=>
[{"name"=>"version", "time_elapsed"=>1.1811964213848114e-05},
{"name"=>"installation_type", "time_elapsed"=>0.00017242692410945892},
{"name"=>"license_billable_users", "time_elapsed"=>0.009520471096038818},
diff --git a/doc/development/service_ping/metrics_dictionary.md b/doc/development/service_ping/metrics_dictionary.md
index f5975276cd8..2adba5d8095 100644
--- a/doc/development/service_ping/metrics_dictionary.md
+++ b/doc/development/service_ping/metrics_dictionary.md
@@ -240,15 +240,17 @@ The generator takes a list of key paths and 3 options as arguments. It creates m
```shell
bundle exec rails generate gitlab:usage_metric_definition counts.issues --dir=7d --class_name=CountIssues
-create config/metrics/counts_7d/issues.yml
+// Creates 1 file
+// create config/metrics/counts_7d/issues.yml
```
**Multiple metrics example**
```shell
bundle exec rails generate gitlab:usage_metric_definition counts.issues counts.users --dir=7d --class_name=CountUsersCreatingIssues
-create config/metrics/counts_7d/issues.yml
-create config/metrics/counts_7d/users.yml
+// Creates 2 files
+// create config/metrics/counts_7d/issues.yml
+// create config/metrics/counts_7d/users.yml
```
NOTE:
@@ -256,7 +258,8 @@ To create a metric definition used in EE, add the `--ee` flag.
```shell
bundle exec rails generate gitlab:usage_metric_definition counts.issues --ee --dir=7d --class_name=CountUsersCreatingIssues
-create ee/config/metrics/counts_7d/issues.yml
+// Creates 1 file
+// create ee/config/metrics/counts_7d/issues.yml
```
### Metrics added dynamic to Service Ping payload
@@ -271,26 +274,29 @@ The generator takes `category` and `events` arguments, as the root key is `redis
```shell
bundle exec rails generate gitlab:usage_metric_definition:redis_hll issues count_users_closing_issues
-create config/metrics/counts_7d/count_users_closing_issues_weekly.yml
-create config/metrics/counts_28d/count_users_closing_issues_monthly.yml
+// Creates 2 files
+// create config/metrics/counts_7d/count_users_closing_issues_weekly.yml
+// create config/metrics/counts_28d/count_users_closing_issues_monthly.yml
```
**Multiple metrics example**
```shell
bundle exec rails generate gitlab:usage_metric_definition:redis_hll issues count_users_closing_issues count_users_reopening_issues
-create config/metrics/counts_7d/count_users_closing_issues_weekly.yml
-create config/metrics/counts_28d/count_users_closing_issues_monthly.yml
-create config/metrics/counts_7d/count_users_reopening_issues_weekly.yml
-create config/metrics/counts_28d/count_users_reopening_issues_monthly.yml
+// Creates 4 files
+// create config/metrics/counts_7d/count_users_closing_issues_weekly.yml
+// create config/metrics/counts_28d/count_users_closing_issues_monthly.yml
+// create config/metrics/counts_7d/count_users_reopening_issues_weekly.yml
+// create config/metrics/counts_28d/count_users_reopening_issues_monthly.yml
```
To create a metric definition used in EE, add the `--ee` flag.
```shell
bundle exec rails generate gitlab:usage_metric_definition:redis_hll issues users_closing_issues --ee
-create config/metrics/counts_7d/i_closed_weekly.yml
-create config/metrics/counts_28d/i_closed_monthly.yml
+// Creates 2 files
+// create config/metrics/counts_7d/i_closed_weekly.yml
+// create config/metrics/counts_28d/i_closed_monthly.yml
```
## Metrics Dictionary
diff --git a/doc/user/admin_area/reporting/git_abuse_rate_limit.md b/doc/user/admin_area/reporting/git_abuse_rate_limit.md
new file mode 100644
index 00000000000..ad3ecfa3a5a
--- /dev/null
+++ b/doc/user/admin_area/reporting/git_abuse_rate_limit.md
@@ -0,0 +1,29 @@
+---
+stage: Anti-Abuse
+group: Anti-Abuse
+info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
+---
+
+# Git abuse rate limit **(ULTIMATE SELF)**
+
+> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/8066) in GitLab 15.2 [with flags](../../../administration/feature_flags.md) named `git_abuse_rate_limit_feature_flag` and `auto_ban_user_on_excessive_projects_download`. Both flags are disabled by default.
+
+FLAG:
+On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flags](../../../administration/feature_flags.md) named `git_abuse_rate_limit_feature_flag` and `auto_ban_user_on_excessive_projects_download`.
+
+Git abuse rate limiting is a feature to automatically [ban users](../moderate_users.md#ban-and-unban-users) who download more than a specified number of repositories in a given time. When the `git_abuse_rate_limit_feature_flag` feature flag is enabled, the administrator receives an email when a user is about to be banned.
+
+When the `auto_ban_user_on_excessive_projects_download` is not enabled, the user is not banned automatically. You can use this setup to determine the correct values of the rate limit settings.
+
+When both flags are enabled, the administrator receives an email when a user is about to be banned, and the user is automatically banned from the GitLab instance.
+
+## Configure Git abuse rate limiting
+
+1. On the top bar, select **Menu > Admin**.
+1. On the left sidebar, select **Settings > Reporting**.
+1. Expand **Git abuse rate limit**.
+1. Update the Git abuse rate limit settings:
+ 1. Enter a number in the **Number of repositories** field, greater than or equal to `0` and less than or equal to `10,000`. This number specifies the maximum amount of unique repositories a user can download in the specified time period before they're banned. When set to `0`, Git abuse rate limiting is disabled.
+ 1. Enter a number in the **Reporting time period (seconds)** field, greater than or equal to `0` and less than or equal to `86,400`. This number specifies the time in seconds a user can download the maximum amount of repositories before they're banned. When set to `0`, Git abuse rate limiting is disabled.
+ 1. Optional. Exclude users by adding them to the **Excluded users** field. Excluded users are not automatically banned.
+1. Select **Save changes**.
diff --git a/doc/user/admin_area/settings/index.md b/doc/user/admin_area/settings/index.md
index 034a432c570..2e27b213f16 100644
--- a/doc/user/admin_area/settings/index.md
+++ b/doc/user/admin_area/settings/index.md
@@ -162,6 +162,7 @@ The **Reporting** settings contain:
- [Spam and Anti-bot Protection](../../../integration/recaptcha.md) -
Enable anti-spam services, like reCAPTCHA, Akismet, or [Spamcheck](../reporting/spamcheck.md), and set IP limits.
- [Abuse reports](../review_abuse_reports.md) - Set notification email for abuse reports.
+- [Git abuse rate limit](../reporting/git_abuse_rate_limit.md) - Configure Git abuse rate limit settings. **(ULTIMATE SELF)**
### Repository
diff --git a/doc/user/application_security/container_scanning/index.md b/doc/user/application_security/container_scanning/index.md
index 9e96f30d915..700e0607ddc 100644
--- a/doc/user/application_security/container_scanning/index.md
+++ b/doc/user/application_security/container_scanning/index.md
@@ -178,6 +178,8 @@ include:
DOCKER_PASSWORD: "$AWS_ECR_PASSWORD"
```
+Authenticating to a remote registry is not supported when [FIPS mode](../../../development/fips_compliance.md#enable-fips-mode) is enabled.
+
#### Dependency list
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/345434) in GitLab 14.6.
@@ -253,8 +255,8 @@ including a large number of false positives.
| `CS_REGISTRY_INSECURE` | `"false"` | Allow access to insecure registries (HTTP only). Should only be set to `true` when testing the image locally. Works with all scanners, but the registry must listen on port `80/tcp` for Trivy to work. | All |
| `CS_SEVERITY_THRESHOLD` | `UNKNOWN` | Severity level threshold. The scanner outputs vulnerabilities with severity level higher than or equal to this threshold. Supported levels are Unknown, Low, Medium, High, and Critical. | Trivy |
| `DOCKER_IMAGE` | `$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG` | The Docker image to be scanned. If set, this variable overrides the `$CI_APPLICATION_REPOSITORY` and `$CI_APPLICATION_TAG` variables. | All |
-| `DOCKER_PASSWORD` | `$CI_REGISTRY_PASSWORD` | Password for accessing a Docker registry requiring authentication. The default is only set if `$DOCKER_IMAGE` resides at [`$CI_REGISTRY`](../../../ci/variables/predefined_variables.md). | All |
-| `DOCKER_USER` | `$CI_REGISTRY_USER` | Username for accessing a Docker registry requiring authentication. The default is only set if `$DOCKER_IMAGE` resides at [`$CI_REGISTRY`](../../../ci/variables/predefined_variables.md). | All |
+| `DOCKER_PASSWORD` | `$CI_REGISTRY_PASSWORD` | Password for accessing a Docker registry requiring authentication. The default is only set if `$DOCKER_IMAGE` resides at [`$CI_REGISTRY`](../../../ci/variables/predefined_variables.md). Not supported when [FIPS mode](../../../development/fips_compliance.md#enable-fips-mode) is enabled. | All |
+| `DOCKER_USER` | `$CI_REGISTRY_USER` | Username for accessing a Docker registry requiring authentication. The default is only set if `$DOCKER_IMAGE` resides at [`$CI_REGISTRY`](../../../ci/variables/predefined_variables.md). Not supported when [FIPS mode](../../../development/fips_compliance.md#enable-fips-mode) is enabled. | All |
| `DOCKERFILE_PATH` | `Dockerfile` | The path to the `Dockerfile` to use for generating remediations. By default, the scanner looks for a file named `Dockerfile` in the root directory of the project. You should configure this variable only if your `Dockerfile` is in a non-standard location, such as a subdirectory. See [Solutions for vulnerabilities](#solutions-for-vulnerabilities-auto-remediation) for more details. | All |
| `SECURE_LOG_LEVEL` | `info` | Set the minimum logging level. Messages of this logging level or higher are output. From highest to lowest severity, the logging levels are: `fatal`, `error`, `warn`, `info`, `debug`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/10880) in GitLab 13.1. | All |
@@ -668,6 +670,8 @@ Also:
- Consider creating credentials with read-only permissions and rotating them regularly if the
options aren't selected.
+Scanning images in external private registries is not supported when [FIPS mode](../../../development/fips_compliance.md#enable-fips-mode) is enabled.
+
## Running the standalone container scanning tool
It's possible to run the [GitLab container scanning tool](https://gitlab.com/gitlab-org/security-products/analyzers/container-scanning)
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index b42d164d9c4..68df2282df6 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -286,7 +286,7 @@ module Gitlab
extend ActiveSupport::Concern
class_methods do
- # A patch over ActiveRecord::Base.transaction that provides
+ # A patch over ApplicationRecord.transaction that provides
# observability into transactional methods.
def transaction(**options, &block)
transaction_type = get_transaction_type(connection.transaction_open?, options[:requires_new])
diff --git a/lib/gitlab/metrics/subscribers/active_record.rb b/lib/gitlab/metrics/subscribers/active_record.rb
index 7c22ce64ea2..c1ecbe994cd 100644
--- a/lib/gitlab/metrics/subscribers/active_record.rb
+++ b/lib/gitlab/metrics/subscribers/active_record.rb
@@ -24,7 +24,7 @@ module Gitlab
# This event is published from ActiveRecordBaseTransactionMetrics and
# used to record a database transaction duration when calling
- # ActiveRecord::Base.transaction {} block.
+ # ApplicationRecord.transaction {} block.
def transaction(event)
observe(:gitlab_database_transaction_seconds, event) do
buckets TRANSACTION_DURATION_BUCKET
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index d49710656e4..3e66a2ff730 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -38045,6 +38045,9 @@ msgstr ""
msgid "TagsPage|Cancel, keep tag"
msgstr ""
+msgid "TagsPage|Create release"
+msgstr ""
+
msgid "TagsPage|Create tag"
msgstr ""
@@ -38063,6 +38066,9 @@ msgstr ""
msgid "TagsPage|Deleting the %{strongStart}%{tagName}%{strongEnd} tag cannot be undone. Are you sure?"
msgstr ""
+msgid "TagsPage|Edit release"
+msgstr ""
+
msgid "TagsPage|Edit release notes"
msgstr ""
diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb
index 921b36b34af..74b7a793f8c 100644
--- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb
+++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb
@@ -135,7 +135,7 @@ module QA
end
end
- context 'duplication setting' do
+ context 'duplication setting', quarantine: { type: :stale, issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/365150' } do
before do
package_project.group.visit!
diff --git a/spec/events/projects/project_path_changed_event_spec.rb b/spec/events/projects/project_path_changed_event_spec.rb
new file mode 100644
index 00000000000..a157428de04
--- /dev/null
+++ b/spec/events/projects/project_path_changed_event_spec.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Projects::ProjectPathChangedEvent do
+ where(:data, :valid) do
+ valid_event = {
+ project_id: 1,
+ namespace_id: 2,
+ root_namespace_id: 3,
+ old_path: 'old',
+ new_path: 'new'
+ }
+
+ # All combinations of missing keys
+ with_missing_keys = 0.upto(valid_event.size - 1)
+ .flat_map { |size| valid_event.keys.combination(size).to_a }
+ .map { |keys| [valid_event.slice(*keys), false] }
+
+ [
+ [valid_event, true],
+ *with_missing_keys,
+ [{ project_id: 'foo', namespace_id: 2 }, false],
+ [{ project_id: 1, namespace_id: 'foo' }, false],
+ [{ project_id: [], namespace_id: 2 }, false],
+ [{ project_id: 1, namespace_id: [] }, false],
+ [{ project_id: {}, namespace_id: 2 }, false],
+ [{ project_id: 1, namespace_id: {} }, false],
+ ['foo', false],
+ [123, false],
+ [[], false]
+ ]
+ end
+
+ with_them do
+ it 'validates data' do
+ constructor = -> { described_class.new(data: data) }
+
+ if valid
+ expect { constructor.call }.not_to raise_error
+ else
+ expect { constructor.call }.to raise_error(Gitlab::EventStore::InvalidEvent)
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/tags/user_edits_tags_spec.rb b/spec/features/projects/tags/user_edits_tags_spec.rb
index 17080043b6d..c8438b73dc3 100644
--- a/spec/features/projects/tags/user_edits_tags_spec.rb
+++ b/spec/features/projects/tags/user_edits_tags_spec.rb
@@ -5,17 +5,58 @@ require 'spec_helper'
RSpec.describe 'Project > Tags', :js do
include DropzoneHelper
- let(:user) { create(:user) }
- let(:role) { :developer }
- let(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:role) { :developer }
+ let_it_be(:project) { create(:project, :repository) }
before do
sign_in(user)
project.add_role(user, role)
end
+ shared_examples "can create and update release" do
+ it 'can create new release' do
+ visit page_url
+ page.find("a[href=\"#{new_project_release_path(project, tag_name: 'v1.1.0')}\"]").click
+
+ fill_in "Release notes", with: "new release from tag"
+ expect(page).not_to have_field("Create from")
+ click_button "Create release"
+
+ expect(page).to have_current_path(project_release_path(project, 'v1.1.0'))
+ expect(Release.last.description).to eq("new release from tag")
+ end
+
+ it 'can edit existing release' do
+ release = create(:release, project: project, tag: 'v1.1.0')
+
+ visit page_url
+ page.find("a[href=\"#{edit_project_release_path(project, release)}\"]").click
+
+ fill_in "Release notes", with: "updated release desc"
+ click_button "Save changes"
+
+ expect(page).to have_current_path(project_release_path(project, 'v1.1.0'))
+ expect(release.reload.description).to eq("updated release desc")
+ end
+ end
+
+ context 'when visiting tags index page' do
+ let(:page_url) { project_tags_path(project) }
+
+ include_examples "can create and update release"
+ end
+
+ context 'when visiting individual tag page' do
+ let(:page_url) { project_tag_path(project, 'v1.1.0') }
+
+ include_examples "can create and update release"
+ end
+
+ # TODO: remove most of these together with FF https://gitlab.com/gitlab-org/gitlab/-/issues/366244
describe 'when opening project tags' do
before do
+ stub_feature_flags(edit_tag_release_notes_via_release_page: false)
visit project_tags_path(project)
end
diff --git a/spec/features/tags/developer_updates_tag_spec.rb b/spec/features/tags/developer_updates_tag_spec.rb
index b2fc28b8493..531ed91c057 100644
--- a/spec/features/tags/developer_updates_tag_spec.rb
+++ b/spec/features/tags/developer_updates_tag_spec.rb
@@ -2,6 +2,7 @@
require 'spec_helper'
+# TODO: remove this file together with FF https://gitlab.com/gitlab-org/gitlab/-/issues/366244
RSpec.describe 'Developer updates tag' do
let(:user) { create(:user) }
let(:group) { create(:group) }
@@ -10,6 +11,7 @@ RSpec.describe 'Developer updates tag' do
before do
project.add_developer(user)
sign_in(user)
+ stub_feature_flags(edit_tag_release_notes_via_release_page: false)
visit project_tags_path(project)
end
diff --git a/spec/services/projects/after_rename_service_spec.rb b/spec/services/projects/after_rename_service_spec.rb
index 442909817e7..9dc15131bc5 100644
--- a/spec/services/projects/after_rename_service_spec.rb
+++ b/spec/services/projects/after_rename_service_spec.rb
@@ -188,6 +188,22 @@ RSpec.describe Projects::AfterRenameService do
)
end
end
+
+ context 'EventStore' do
+ let(:project) { create(:project, :repository, skip_disk_validation: true) }
+
+ it 'publishes a ProjectPathChangedEvent' do
+ expect { service_execute }
+ .to publish_event(Projects::ProjectPathChangedEvent)
+ .with(
+ project_id: project.id,
+ namespace_id: project.namespace_id,
+ root_namespace_id: project.root_namespace.id,
+ old_path: full_path_before_rename,
+ new_path: full_path_after_rename
+ )
+ end
+ end
end
def service_execute
diff --git a/spec/services/service_ping/submit_service_ping_service_spec.rb b/spec/services/service_ping/submit_service_ping_service_spec.rb
index 07e3d99e679..b863b2a46b0 100644
--- a/spec/services/service_ping/submit_service_ping_service_spec.rb
+++ b/spec/services/service_ping/submit_service_ping_service_spec.rb
@@ -385,24 +385,26 @@ RSpec.describe ServicePing::SubmitService do
let(:metric_double) { instance_double(Gitlab::Usage::ServicePing::LegacyMetricTimingDecorator, duration: 123) }
let(:payload) do
{
- metric_a: metric_double,
- metric_group: {
- metric_b: metric_double
- },
- metric_without_timing: "value",
- recorded_at: Time.current
- }
+ uuid: 'uuid',
+ metric_a: metric_double,
+ metric_group: {
+ metric_b: metric_double
+ },
+ metric_without_timing: "value",
+ recorded_at: Time.current
+ }
end
let(:metadata_payload) do
{
metadata: {
- metrics: [
- { name: 'metric_a', time_elapsed: 123 },
- { name: 'metric_group.metric_b', time_elapsed: 123 }
- ]
+ uuid: 'uuid',
+ metrics: [
+ { name: 'metric_a', time_elapsed: 123 },
+ { name: 'metric_group.metric_b', time_elapsed: 123 }
+ ]
+ }
}
- }
end
it 'submits metadata' do