Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2024-12-16 05:01:35 +00:00
parent 1185bb82f5
commit a50b8cefe8
20 changed files with 264 additions and 19 deletions

View File

@ -2,7 +2,6 @@
# Cop supports --autocorrect.
Layout/ArgumentAlignment:
Exclude:
- 'ee/app/services/ee/keys/create_service.rb'
- 'ee/app/services/ee/projects/create_from_template_service.rb'
- 'ee/app/services/ee/projects/gitlab_projects_import_service.rb'
- 'ee/app/services/ee/search/snippet_service.rb'

View File

@ -1 +1 @@
c4214a8f59358bcca78e06f5e4d5bbb8e19cc03b
eee36c7f647a6ecbc1398349520fce14a021008e

View File

@ -0,0 +1,37 @@
# frozen_string_literal: true
module Mutations
module Branches # rubocop:disable Gitlab/BoundedContexts -- Existing module
class Delete < BaseMutation
graphql_name 'BranchDelete'
include FindsProject
argument :project_path, GraphQL::Types::ID,
required: true,
description: 'Project full path the branch is associated with.'
argument :name, GraphQL::Types::String,
required: true,
description: 'Name of the branch.'
field :branch,
Types::BranchType,
null: true,
description: 'Branch after mutation.'
authorize :push_code
def resolve(project_path:, name:)
project = authorized_find!(project_path)
result = ::Branches::DeleteService.new(project, current_user).execute(name)
{
branch: (result.payload[:branch] if result.error?),
errors: result.errors
}
end
end
end
end

View File

@ -40,6 +40,7 @@ module Types
mount_mutation Mutations::Boards::Lists::Update
mount_mutation Mutations::Boards::Lists::Destroy
mount_mutation Mutations::Branches::Create, calls_gitaly: true
mount_mutation Mutations::Branches::Delete, calls_gitaly: true
mount_mutation Mutations::Clusters::Agents::Create
mount_mutation Mutations::Clusters::Agents::Delete
mount_mutation Mutations::Clusters::AgentTokens::Create

View File

@ -131,6 +131,17 @@ class DiffNote < Note
end
end
def latest_diff_file_path
latest_diff_file.file_path
end
def raw_truncated_diff_lines
discussion
.truncated_diff_lines(highlight: false)
.map(&:text)
.join("\n")
end
private
def enqueue_diff_file_creation_job

View File

@ -24,11 +24,12 @@ module Branches
ServiceResponse.success(message: 'Branch was deleted')
else
ServiceResponse.error(
payload: { branch: branch },
message: 'Failed to remove branch',
http_status: 400)
end
rescue Gitlab::Git::PreReceiveError, Gitlab::Git::CommandError => ex
ServiceResponse.error(message: ex.message, http_status: 400)
ServiceResponse.error(payload: { branch: branch }, message: ex.message, http_status: 400)
end
private

View File

@ -541,6 +541,8 @@
- 1
- - merge_requests_delete_source_branch
- 1
- - merge_requests_duo_code_review_chat
- 1
- - merge_requests_execute_approval_hooks
- 1
- - merge_requests_fetch_suggested_reviewers

View File

@ -0,0 +1,41 @@
- title: "Updated tooling to release CI/CD components to the Catalog"
announcement_milestone: "17.7"
removal_milestone: "18.0"
breaking_change: true
reporter: dhershkovitch
stage: verify
issue_url: https://gitlab.com/groups/gitlab-org/-/epics/12788
window: 3 # Can be 1, 2, or 3 - The window when the breaking change will be deployed on GitLab.com
# Use the impact calculator https://gitlab-com.gitlab.io/gl-infra/breaking-change-impact-calculator/?
impact: high # Can be one of: [critical, high, medium, low]
scope: # Can be one or a combination of: [instance, group, project]
resolution_role: Developer # Can be one of: [Admin, Owner, Maintainer, Developer]
manual_task: true # Can be true or false. Use this to denote whether a resolution action must be performed manually (true), or if it can be automated by using the API or other automation (false).
body: | # (required) Don't change this line.
Starting in GitLab 18.0, the internal process that releases CI/CD components to the Catalog will be changed.
If you use the [recommended CI/CD component release process](https://docs.gitlab.com/ee/ci/components/#publish-a-new-release), which makes use of the `release` keyword and the `registry.gitlab.com/gitlab-org/release-cli:latest` container image, you do not need to make any changes.
The `latest` version of this container image (`v0.20.0`) contains [GLab](https://gitlab.com/gitlab-org/cli/) `v1.50.0`, which will be used for all releases to the CI/CD Catalog in GitLab 18.0 and later.
In other cases:
- If you need to pin the container image to a specific version, use `v0.20.0` or later (`registry.gitlab.com/gitlab-org/release-cli:v0.20.0`),
to ensure GLab is available for the release process.
- If you've manually installed the Release CLI tool on your runners, you must install GLab `v1.50.0` or later on those runners.
# ==============================
# OPTIONAL END-OF-SUPPORT FIELDS
# ==============================
#
# If an End of Support period applies:
# 1) Share this announcement in the `#spt_managers` Support channel in Slack
# 2) Mention `@gitlab-com/support` in this merge request.
#
# When support for this feature ends, in XX.YY milestone format.
end_of_support_milestone:
# Array of tiers the feature is currently available to,
# like [Free, Silver, Gold, Core, Premium, Ultimate]
tiers:
# Links to documentation and thumbnail image
documentation_url:
image_url:
# Use the youtube thumbnail URL with the structure of https://img.youtube.com/vi/UNIQUEID/hqdefault.jpg
video_url:

View File

@ -2784,6 +2784,26 @@ Input type: `BoardListUpdateLimitMetricsInput`
| <a id="mutationboardlistupdatelimitmetricserrors"></a>`errors` | [`[String!]!`](#string) | Errors encountered during execution of the mutation. |
| <a id="mutationboardlistupdatelimitmetricslist"></a>`list` | [`BoardList`](#boardlist) | Updated list. |
### `Mutation.branchDelete`
Input type: `BranchDeleteInput`
#### Arguments
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="mutationbranchdeleteclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
| <a id="mutationbranchdeletename"></a>`name` | [`String!`](#string) | Name of the branch. |
| <a id="mutationbranchdeleteprojectpath"></a>`projectPath` | [`ID!`](#id) | Project full path the branch is associated with. |
#### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="mutationbranchdeletebranch"></a>`branch` | [`Branch`](#branch) | Branch after mutation. |
| <a id="mutationbranchdeleteclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
| <a id="mutationbranchdeleteerrors"></a>`errors` | [`[String!]!`](#string) | Errors encountered during execution of the mutation. |
### `Mutation.branchRuleApprovalProjectRuleCreate`
DETAILS:

View File

@ -74,5 +74,6 @@ This window takes place on May 5 - 7, 2025 from 09:00 UTC to 22:00 UTC.
| [`ciJobTokenScopeAddProject` GraphQL mutation is deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/474175) | Low | Govern | Project |
| [Guest users can pull packages from private projects on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/336622) | High | Package | Project |
| [Removal of `migrationState` field in `ContainerRepository` GraphQL API](https://gitlab.com/gitlab-org/gitlab/-/issues/459869) | Low | Package | Project |
| [Updated tooling to release CI/CD components to the Catalog](https://gitlab.com/groups/gitlab-org/-/epics/12788) | High | Verify | |
| [Increased default security for use of pipeline variables](https://gitlab.com/gitlab-org/gitlab/-/issues/502382) | Medium | Verify | Project |
| [Remove `previousStageJobsOrNeeds` from GraphQL](https://gitlab.com/gitlab-org/gitlab/-/issues/424417) | | Verify | |

View File

@ -1198,6 +1198,29 @@ Toggling notes confidentiality with REST and GraphQL APIs is being deprecated. U
<div class="deprecation breaking-change" data-milestone="18.0">
### Updated tooling to release CI/CD components to the Catalog
<div class="deprecation-notes">
- Announced in GitLab <span class="milestone">17.7</span>
- Removal in GitLab <span class="milestone">18.0</span> ([breaking change](https://docs.gitlab.com/ee/update/terminology.html#breaking-change))
- To discuss this change or learn more, see the [deprecation issue](https://gitlab.com/groups/gitlab-org/-/epics/12788).
</div>
Starting in GitLab 18.0, the internal process that releases CI/CD components to the Catalog will be changed.
If you use the [recommended CI/CD component release process](https://docs.gitlab.com/ee/ci/components/#publish-a-new-release), which makes use of the `release` keyword and the `registry.gitlab.com/gitlab-org/release-cli:latest` container image, you do not need to make any changes.
The `latest` version of this container image (`v0.20.0`) contains [GLab](https://gitlab.com/gitlab-org/cli/) `v1.50.0`, which will be used for all releases to the CI/CD Catalog in GitLab 18.0 and later.
In other cases:
- If you need to pin the container image to a specific version, use `v0.20.0` or later (`registry.gitlab.com/gitlab-org/release-cli:v0.20.0`),
to ensure GLab is available for the release process.
- If you've manually installed the Release CLI tool on your runners, you must install GLab `v1.50.0` or later on those runners.
</div>
<div class="deprecation breaking-change" data-milestone="18.0">
### Workspaces `editor` GraphQL field is deprecated
<div class="deprecation-notes">

View File

@ -4,7 +4,7 @@ group: Optimize
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
---
# AI Impact analytics
# AI impact analytics
DETAILS:
**Tier:** Ultimate with GitLab Duo Enterprise - [Start a trial](https://about.gitlab.com/solutions/gitlab-duo-pro/sales/?type=free-trial)
@ -14,20 +14,20 @@ DETAILS:
> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/451873) in GitLab 17.2. Feature flag `ai_impact_analytics_dashboard` removed.
> - Changed to require GitLab Duo add-on in GitLab 17.6.
AI Impact analytics displays software development lifecycle (SDLC) metrics for a project or group in the month-to-date and the past six months.
AI impact analytics displays software development lifecycle (SDLC) metrics for a project or group in the month-to-date and the past six months.
Use AI Impact analytics to:
Use AI impact analytics to:
- Measure the effectiveness and impact of AI on SDLC metrics.
- Visualize which metrics improved as a result of investments in AI.
- Track the progress of AI adoption.
- Compare the performance of teams that are using AI against teams that are not using AI.
For a click-through demo, see the [AI Impact analytics product tour](https://gitlab.navattic.com/ai-impact).
For a click-through demo, see the [AI impact analytics product tour](https://gitlab.navattic.com/ai-impact).
## AI Impact metrics
## AI impact metrics
AI Impact analytics displays key metrics and metric trends for a project or group.
AI impact analytics displays key metrics and metric trends for a project or group.
### Key metrics
@ -52,14 +52,14 @@ The **Metric trends** table displays metrics for the last six months, with month
**Code Suggestions usage**: Monthly user engagement with AI Code Suggestions.
- The month-over-month comparison of the AI Usage unique users rate gives a more accurate indication of this metric, as it eliminates factors such as developer experience level and project type or complexity.
- The baseline for the AI Usage trend is the total number of code contributors, not just users with GitLab Duo seats. This baseline gives a more accurate representation of AI usage by team members. To learn more about AI Impact analytics, see the blog post [Developing GitLab Duo: AI Impact analytics dashboard measures the ROI of AI](https://about.gitlab.com/blog/2024/05/15/developing-gitlab-duo-ai-impact-analytics-dashboard-measures-the-roi-of-ai/).
- To analyze the performance of teams that use AI versus teams that don't, you can create a custom [Value Streams Dashboard Scheduled Report](https://gitlab.com/explore/catalog/components/vsd-reports-generator) based on the AI Impact view of projects and groups with and without GitLab Duo.
- The baseline for the AI Usage trend is the total number of code contributors, not just users with GitLab Duo seats. This baseline gives a more accurate representation of AI usage by team members. To learn more about AI impact analytics, see the blog post [Developing GitLab Duo: AI impact analytics dashboard measures the ROI of AI](https://about.gitlab.com/blog/2024/05/15/developing-gitlab-duo-ai-impact-analytics-dashboard-measures-the-roi-of-ai/).
- To analyze the performance of teams that use AI versus teams that don't, you can create a custom [Value Streams Dashboard Scheduled Report](https://gitlab.com/explore/catalog/components/vsd-reports-generator) based on the AI impact view of projects and groups with and without GitLab Duo.
NOTE:
Usage rate for Code Suggestions is calculated with data starting from GitLab 16.11.
For more information, see [epic 12978](https://gitlab.com/groups/gitlab-org/-/epics/12978).
## View AI Impact analytics
## View AI impact analytics
Prerequisites:
@ -70,9 +70,9 @@ Prerequisites:
1. Select **Analyze > Analytics Dashboards**.
1. Select **AI impact analytics**.
To retrieve AI Impact metrics, you can also use the following GraphQL APIs:
To retrieve AI impact metrics, you can also use the following GraphQL APIs:
- [`AiUserMetrics`](../../api/graphql/reference/index.md#aiusermetrics)
- [`AiUserMetrics`](../../api/graphql/reference/index.md#aiusermetrics)
- Requires ClickHouse
- Ultimate with GitLab Duo Pro or Enterprise
- [`AiUsageData`](../../api/graphql/reference/index.md#aiusagedata) - Does not require ClickHouse

View File

@ -82,7 +82,7 @@ Project permissions for [analytics](../user/analytics/index.md) features includi
| View [DORA metrics](analytics/ci_cd_analytics.md) | | | ✓ | ✓ | ✓ | ✓ | |
| View [merge request analytics](analytics/merge_request_analytics.md) | | | ✓ | ✓ | ✓ | ✓ | |
| View [repository analytics](analytics/repository_analytics.md) | | | ✓ | ✓ | ✓ | ✓ | |
| View [Value Streams Dashboard & AI Impact analytics](analytics/value_streams_dashboard.md) | | | ✓ | ✓ | ✓ | ✓ | |
| View [Value Streams Dashboard & AI impact analytics](analytics/value_streams_dashboard.md) | | | ✓ | ✓ | ✓ | ✓ | |
### Application security

View File

@ -6717,7 +6717,7 @@ msgstr ""
msgid "Analytics|Invalid visualization configuration"
msgstr ""
msgid "Analytics|Learn more about %{docsLinkStart}AI Impact analytics%{docsLinkEnd} and %{subscriptionLinkStart}GitLab Duo Pro seats usage%{subscriptionLinkEnd}."
msgid "Analytics|Learn more about %{docsLinkStart}AI impact analytics%{docsLinkEnd} and %{subscriptionLinkStart}GitLab Duo Pro seat usage%{subscriptionLinkEnd}."
msgstr ""
msgid "Analytics|Line chart"
@ -20565,7 +20565,7 @@ msgstr ""
msgid "DuoCodeReview|I have encountered some issues while I was reviewing. Please try again later."
msgstr ""
msgid "DuoEnterpriseDiscover|AI Impact analytics dashboard measures the ROI of AI"
msgid "DuoEnterpriseDiscover|AI Impact Dashboard measures the ROI of AI"
msgstr ""
msgid "DuoEnterpriseDiscover|AI-assisted root cause analysis for CI/CD job failures, and suggested fixes to quickly remedy broken pipelines."

View File

@ -347,7 +347,9 @@ module QA
end
match_when_negated do |page|
page.has_no_element?('merge-button', disabled: false)
has_css?('.mr-widget-section', text: 'Merge blocked') || # Merge widget indicates merge is blocked
page.has_no_element?('merge-button') || # No merge button
page.find_element('merge-button').disabled? == true # There is a merge button, but it is disabled
end
end

View File

@ -540,7 +540,7 @@ module QA
return if mirror_succeeded
mirror_error = api_resource[:import_error] || 'Did not complete within 360 seconds'
raise "Mirroring was not successful: #{mirror_error}}"
raise "Mirroring was not successful: #{mirror_error}"
end
def remove_via_api!

View File

@ -633,4 +633,30 @@ RSpec.describe DiffNote do
end
end
end
describe '#latest_diff_file_path' do
let(:diff_note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
it 'returns the file_path of latest_diff_file' do
expect(diff_note.latest_diff_file_path).to eq(diff_note.latest_diff_file.file_path)
end
end
describe '#raw_truncated_diff_lines' do
let(:diff_note) { build_stubbed(:diff_note_on_merge_request, noteable: merge_request, project: project) }
before do
allow(diff_note)
.to receive_message_chain(:discussion, :truncated_diff_lines)
.and_return([
instance_double(Gitlab::Diff::Line, text: "+line 1"),
instance_double(Gitlab::Diff::Line, text: "+line 2"),
instance_double(Gitlab::Diff::Line, text: "-line 3")
])
end
it 'returns raw truncated diff lines' do
expect(diff_note.raw_truncated_diff_lines).to eq("+line 1\n+line 2\n-line 3")
end
end
end

View File

@ -0,0 +1,63 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Deletion of a branch', feature_category: :source_code_management do
include GraphqlHelpers
let_it_be(:group) { create(:group, :public) }
let_it_be(:current_user) { create(:user) }
let(:input) { { project_path: project_path, name: branch_name } }
let(:project_path) { project.full_path }
let(:branch_name) { 'master' }
let(:mutation) { graphql_mutation(:branch_delete, input) }
let(:mutation_response) { graphql_mutation_response(:branch_delete) }
shared_examples 'deletes a branch' do
specify do
expect(project.repository.find_branch(branch_name)).to be_present
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
expect(mutation_response).to have_key('branch')
expect(mutation_response['branch']).to be_nil
expect(mutation_response['errors']).to be_empty
expect(project.repository.find_branch(branch_name)).to be_nil
end
end
context 'when project is public' do
let(:project) { create(:project, :public, :small_repo) }
context 'when user is not allowed to delete a branch' do
it_behaves_like 'a mutation that returns a top-level access error'
end
context 'when user is a direct project member' do
context 'and user is a developer' do
before do
project.add_developer(current_user)
end
it_behaves_like 'deletes a branch'
context 'when ref is not correct' do
let(:branch_name) { 'unknown' }
it_behaves_like 'a mutation that returns errors in the response', errors: ['No such branch']
end
context 'when path is not correct' do
let(:project_path) { 'unknown' }
it_behaves_like 'a mutation that returns a top-level access error'
end
end
end
end
end

View File

@ -50,6 +50,7 @@ RSpec.describe Branches::DeleteService, feature_category: :source_code_managemen
expect(result.status).to eq(:error)
expect(result.message).to eq('Could not update patch')
expect(result.payload[:branch]).to be_kind_of(Gitlab::Git::Branch)
end
end
@ -59,6 +60,21 @@ RSpec.describe Branches::DeleteService, feature_category: :source_code_managemen
expect(result.status).to eq(:error)
expect(result.message).to eq('No such branch')
expect(result.payload[:branch]).to be_nil
end
end
context 'when Gitaly fails to remove branch' do
before do
allow(repository).to receive(:rm_branch).and_return(false)
end
it 'handles and returns error' do
result = service.execute('feature')
expect(result.status).to eq(:error)
expect(result.message).to eq('Failed to remove branch')
expect(result.payload[:branch]).to be_kind_of(Gitlab::Git::Branch)
end
end
end
@ -71,6 +87,7 @@ RSpec.describe Branches::DeleteService, feature_category: :source_code_managemen
expect(result.status).to eq :error
expect(result.message).to eq 'You dont have push access to repo'
expect(result.payload[:branch]).to be_nil
expect(branch_exists?('feature')).to be true
end
end

View File

@ -357,6 +357,7 @@ RSpec.describe 'Every Sidekiq worker', feature_category: :shared do
'MergeRequests::CleanupRefWorker' => 3,
'MergeRequests::CreatePipelineWorker' => 3,
'MergeRequests::DeleteSourceBranchWorker' => 3,
'MergeRequests::DuoCodeReviewChatWorker' => 3,
'MergeRequests::FetchSuggestedReviewersWorker' => 3,
'MergeRequests::HandleAssigneesChangeWorker' => 3,
'MergeRequests::MergeabilityCheckBatchWorker' => 3,