Skip to content

Commit de0a169

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 84829ca commit de0a169

File tree

14 files changed

+204
-19
lines changed

14 files changed

+204
-19
lines changed

app/assets/javascripts/behaviors/shortcuts/shortcuts_work_items.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export default class ShortcutsWorkItem {
5959
setTimeout(() => {
6060
const shortcutSelector = `.${selector} .shortcut-sidebar-dropdown-toggle`;
6161
const editBtn =
62-
document.querySelector(`.is-modal ${shortcutSelector}`) ||
62+
document.querySelector(`.gl-drawer ${shortcutSelector}`) ||
63+
document.querySelector(`.modal ${shortcutSelector}`) ||
6364
document.querySelector(shortcutSelector);
6465
editBtn?.click();
6566
}, DEBOUNCE_DROPDOWN_DELAY);
@@ -69,13 +70,23 @@ export default class ShortcutsWorkItem {
6970
static editDescription() {
7071
// Need to click the element as on issues, editing is inline
7172
// on merge request, editing is on a different page
72-
document.querySelector('.shortcut-edit-wi-description')?.click();
73+
const editDescriptionSelector = '.shortcut-edit-wi-description';
74+
const editButton =
75+
document.querySelector(`.gl-drawer ${editDescriptionSelector}`) ||
76+
document.querySelector(`.modal ${editDescriptionSelector}`) ||
77+
document.querySelector(editDescriptionSelector);
78+
79+
editButton?.click();
7380

7481
return false;
7582
}
7683

7784
async copyReference() {
78-
const refButton = document.querySelector('.shortcut-copy-reference');
85+
const refSelector = '.shortcut-copy-reference';
86+
const refButton =
87+
document.querySelector(`.gl-drawer ${refSelector}`) ||
88+
document.querySelector(`.modal ${refSelector}`) ||
89+
document.querySelector(refSelector);
7990
const copiedRef = refButton?.dataset.clipboardText;
8091

8192
if (copiedRef) {
@@ -88,7 +99,9 @@ export default class ShortcutsWorkItem {
8899
static replyWithSelectedText() {
89100
const gfmSelector = '.js-vue-markdown-field .js-gfm-input';
90101
let replyField =
91-
document.querySelector(`.modal ${gfmSelector}`) || document.querySelector(gfmSelector);
102+
document.querySelector(`.gl-drawer ${gfmSelector}`) ||
103+
document.querySelector(`.modal ${gfmSelector}`) ||
104+
document.querySelector(gfmSelector);
92105

93106
// Ensure that markdown input is still present in the DOM
94107
// otherwise fall back to main comment input field.

app/controllers/projects/merge_requests/application_controller.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ def close_merge_request_if_no_source_project
8585

8686
@merge_request.close
8787
end
88+
89+
# rubocop: disable CodeReuse/ActiveRecord
90+
def commit
91+
commit_id = params[:commit_id].presence
92+
return unless commit_id
93+
94+
return unless @merge_request.all_commits.exists?(sha: commit_id) ||
95+
@merge_request.recent_context_commits.map(&:id).include?(commit_id)
96+
97+
@commit ||= @project.commit(commit_id)
98+
end
99+
# rubocop: enable CodeReuse/ActiveRecord
88100
end
89101

90102
Projects::MergeRequests::ApplicationController.prepend_mod_with('Projects::MergeRequests::ApplicationController')

app/controllers/projects/merge_requests/diffs_controller.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,6 @@ def define_diff_vars
134134
render_404 unless @compare
135135
end
136136

137-
# rubocop: disable CodeReuse/ActiveRecord
138-
def commit
139-
return unless commit_id = params[:commit_id].presence
140-
return unless @merge_request.all_commits.exists?(sha: commit_id) ||
141-
@merge_request.recent_context_commits.map(&:id).include?(commit_id)
142-
143-
@commit ||= @project.commit(commit_id)
144-
end
145-
# rubocop: enable CodeReuse/ActiveRecord
146-
147137
# rubocop: disable CodeReuse/ActiveRecord
148138
#
149139
# Deprecated: https://gitlab.com/gitlab-org/gitlab/issues/37735

app/controllers/projects/merge_requests_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ def render_html_page
477477
end
478478

479479
def get_diffs_count
480+
return @commit.raw_diffs.size if commit
480481
return @merge_request.context_commits_diff.raw_diffs.size if show_only_context_commits?
481482
return @merge_request.merge_request_diffs.find_by_id(params[:diff_id])&.size if params[:diff_id]
482483
return @merge_request.merge_head_diff.size if @merge_request.diffable_merge_ref? && params[:start_sha].blank?
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# frozen_string_literal: true
2+
3+
module Mutations
4+
module Ci
5+
module Pipeline
6+
class Create < BaseMutation
7+
graphql_name 'PipelineCreate'
8+
9+
include FindsProject
10+
11+
field :pipeline,
12+
Types::Ci::PipelineType,
13+
null: true,
14+
description: 'Pipeline created after mutation.'
15+
16+
argument :project_path, GraphQL::Types::ID,
17+
required: true,
18+
description: 'Full path of the project that is triggering the pipeline.'
19+
20+
argument :ref, GraphQL::Types::String,
21+
required: true,
22+
description: 'Ref on which to run the pipeline.'
23+
24+
argument :variables, [Types::Ci::VariableInputType],
25+
required: false,
26+
description: 'Variables for the pipeline.'
27+
28+
authorize :create_pipeline
29+
30+
def resolve(project_path:, **params)
31+
project = authorized_find!(project_path)
32+
33+
response = ::Ci::CreatePipelineService
34+
.new(project, current_user, params)
35+
.execute(:web, ignore_skip_ci: true, save_on_errors: false)
36+
37+
if response.success?
38+
{ pipeline: response.payload, errors: [] }
39+
else
40+
{ pipeline: nil, errors: [response.message] }
41+
end
42+
end
43+
end
44+
end
45+
end
46+
end

app/graphql/types/mutation_type.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class MutationType < BaseObject
176176
mount_mutation Mutations::Ci::JobTokenScope::RemoveProject
177177
mount_mutation Mutations::Ci::JobTokenScope::UpdateJobTokenPolicies, experiment: { milestone: '17.6' }
178178
mount_mutation Mutations::Ci::Pipeline::Cancel
179+
mount_mutation Mutations::Ci::Pipeline::Create
179180
mount_mutation Mutations::Ci::Pipeline::Destroy
180181
mount_mutation Mutations::Ci::Pipeline::Retry
181182
mount_mutation Mutations::Ci::PipelineSchedule::Create

doc/api/graphql/reference/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7940,6 +7940,27 @@ Input type: `PipelineCancelInput`
79407940
| <a id="mutationpipelinecancelclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
79417941
| <a id="mutationpipelinecancelerrors"></a>`errors` | [`[String!]!`](#string) | Errors encountered during execution of the mutation. |
79427942

7943+
### `Mutation.pipelineCreate`
7944+
7945+
Input type: `PipelineCreateInput`
7946+
7947+
#### Arguments
7948+
7949+
| Name | Type | Description |
7950+
| ---- | ---- | ----------- |
7951+
| <a id="mutationpipelinecreateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
7952+
| <a id="mutationpipelinecreateprojectpath"></a>`projectPath` | [`ID!`](#id) | Full path of the project that is triggering the pipeline. |
7953+
| <a id="mutationpipelinecreateref"></a>`ref` | [`String!`](#string) | Ref on which to run the pipeline. |
7954+
| <a id="mutationpipelinecreatevariables"></a>`variables` | [`[CiVariableInput!]`](#civariableinput) | Variables for the pipeline. |
7955+
7956+
#### Fields
7957+
7958+
| Name | Type | Description |
7959+
| ---- | ---- | ----------- |
7960+
| <a id="mutationpipelinecreateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
7961+
| <a id="mutationpipelinecreateerrors"></a>`errors` | [`[String!]!`](#string) | Errors encountered during execution of the mutation. |
7962+
| <a id="mutationpipelinecreatepipeline"></a>`pipeline` | [`Pipeline`](#pipeline) | Pipeline created after mutation. |
7963+
79437964
### `Mutation.pipelineDestroy`
79447965

79457966
Input type: `PipelineDestroyInput`

doc/operations/logs.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ DETAILS:
1111
**Offering:** GitLab.com, Self-managed
1212
**Status:** Beta
1313

14+
NOTE:
15+
This feature is not under active development.
16+
1417
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/143027) in GitLab 16.10 [with a flag](../administration/feature_flags.md) named `observability_logs`. Disabled by default. This feature is in [beta](../policy/experiment-beta-support.md#beta).
1518
> - Feature flag [changed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/158786) in GitLab 17.3 to the `observability_features` [feature flag](../administration/feature_flags.md), disabled by default. The previous feature flag (`observability_logs`) was removed.
1619
> - [Introduced](https://gitlab.com/groups/gitlab-org/opstrace/-/epics/100) for self-managed in GitLab 17.3.
20+
> - [Changed](https://gitlab.com/gitlab-com/marketing/digital-experience/buyer-experience/-/issues/4198) to internal Beta in GitLab 17.7.
1721
1822
FLAG:
1923
The availability of this feature is controlled by a feature flag.

doc/operations/metrics.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ DETAILS:
1111
**Offering:** GitLab.com, Self-managed
1212
**Status:** Beta
1313

14+
NOTE:
15+
This feature is not under active development.
16+
1417
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124966) in GitLab 16.7 [with a flag](../administration/feature_flags.md) named `observability_metrics`. Disabled by default. This feature is an [experiment](../policy/experiment-beta-support.md#experiment).
1518
> - Feature flag [changed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/158786) in GitLab 17.3 to the `observability_features` [feature flag](../administration/feature_flags.md), disabled by default. The previous feature flag (`observability_metrics`) was removed.
1619
> - [Introduced](https://gitlab.com/groups/gitlab-org/opstrace/-/epics/100) for self-managed in GitLab 17.3.
20+
> - [Changed](https://gitlab.com/gitlab-com/marketing/digital-experience/buyer-experience/-/issues/4198) to internal beta in GitLab 17.7.
1721
1822
FLAG:
1923
The availability of this feature is controlled by a feature flag.

doc/operations/tracing.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ DETAILS:
1111
**Offering:** GitLab.com, Self-managed
1212
**Status:** Beta
1313

14+
NOTE:
15+
This feature is not under active development.
16+
1417
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124966) in GitLab 16.2 [with a flag](../administration/feature_flags.md) named `observability_tracing`. Disabled by default. This feature is in [beta](../policy/experiment-beta-support.md#beta).
1518
> - Feature flag [changed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/158786) in GitLab 17.3 to the `observability_features` [feature flag](../administration/feature_flags.md), disabled by default. The previous feature flag `observability_tracing` was removed.
1619
> - [Introduced](https://gitlab.com/groups/gitlab-org/opstrace/-/epics/100) for self-managed in GitLab 17.3.
20+
> - [Changed](https://gitlab.com/gitlab-com/marketing/digital-experience/buyer-experience/-/issues/4198) to internal beta in GitLab 17.7.
1721
1822
FLAG:
1923
The availability of this feature is controlled by a feature flag.

doc/subscriptions/gitlab_com/compute_minutes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DETAILS:
1212

1313
[Compute minutes](../../ci/pipelines/compute_minutes.md) is the resource consumed
1414
when running [CI/CD pipelines](../../ci/index.md) on GitLab instance runners. You can find
15-
pricing for additional compute minutes on the [GitLab Pricing page](https://about.gitlab.com/pricing/).
15+
pricing for additional compute minutes on the [GitLab Pricing page](https://about.gitlab.com/pricing/#compute-minutes).
1616

1717
Additional compute minutes:
1818

spec/features/merge_request/user_views_diffs_commit_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,28 @@
88
end
99

1010
let(:project) { create(:project, :public, :repository) }
11+
let(:commit_id) { merge_request.diff_head_sha }
1112

1213
before do
13-
visit(diffs_project_merge_request_path(project, merge_request, commit_id: merge_request.diff_head_sha))
14+
visit(diffs_project_merge_request_path(project, merge_request, commit_id: commit_id))
1415
end
1516

1617
it 'shows full commit description by default' do
17-
expect(page).to have_selector('.commit-row-description', visible: true)
18+
within_testid('commit-content') do
19+
expect(page).to have_content("Add submodule from gitlab.com")
20+
end
21+
end
22+
23+
it 'shows correct commit metadata' do
24+
expect(page).to have_content("Viewing commit #{commit_id[..7]}")
25+
within_testid('diffs-tab') do
26+
expect(page).to have_content('Changes 2')
27+
end
28+
page.within('#diffs') do
29+
expect(page).to have_content('2 files')
30+
end
31+
within_testid('file-tree-container') do
32+
expect(page).to have_content('Files 2')
33+
end
1834
end
1935
end

spec/requests/api/graphql/mutations/ci/pipeline/cancel_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
expect(build).not_to be_canceled
3737
end
3838

39-
context 'when running build' do
39+
context 'when a build is running' do
4040
let!(:job) { create(:ci_build, :running, pipeline: pipeline) }
4141

4242
context 'when supports canceling is true' do
@@ -52,7 +52,7 @@
5252
end
5353

5454
context 'when supports canceling is false' do
55-
it 'cancels all running jobs to canceled', :sidekiq_inline do
55+
it 'updates all running jobs to `canceled`', :sidekiq_inline do
5656
post_graphql_mutation(mutation, current_user: user)
5757

5858
expect(response).to have_gitlab_http_status(:success)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
RSpec.describe 'PipelineCreate', feature_category: :pipeline_composition do
6+
include GraphqlHelpers
7+
8+
let_it_be(:project) { create(:project, :public, :repository) }
9+
10+
let(:mutation) do
11+
variables = {
12+
project_path: project.full_path,
13+
**params
14+
}
15+
16+
graphql_mutation(
17+
:pipeline_create,
18+
variables,
19+
<<-QL
20+
errors
21+
pipeline {
22+
id
23+
}
24+
QL
25+
)
26+
end
27+
28+
let(:params) { { ref: 'master', variables: [] } }
29+
30+
let(:mutation_response) { graphql_mutation_response(:pipeline_create) }
31+
32+
it 'returns an error if the user is not allowed to create a pipeline' do
33+
post_graphql_mutation(mutation, current_user: build(:user))
34+
35+
expect(graphql_errors.first['message']).to include("you don't have permission to perform this action")
36+
end
37+
38+
context 'when the user is authorized' do
39+
let_it_be(:user) { create(:user) }
40+
41+
before_all do
42+
project.add_developer(user)
43+
end
44+
45+
context 'when the pipeline creation is not successful' do
46+
it 'returns error' do
47+
expect_next_instance_of(::Ci::CreatePipelineService, project, user, params) do |service|
48+
expect(service).to receive(:execute).and_return(ServiceResponse.error(message: 'Error'))
49+
end
50+
51+
post_graphql_mutation(mutation, current_user: user)
52+
53+
expect(mutation_response['errors']).to include('Error')
54+
expect(mutation_response['pipeline']).to be_nil
55+
end
56+
end
57+
58+
context 'when the pipeline creation is successful' do
59+
it 'creates a pipeline' do
60+
pipeline = create(:ci_pipeline, project: project)
61+
62+
expect_next_instance_of(::Ci::CreatePipelineService, project, user, params) do |service|
63+
expect(service).to receive(:execute).and_return(ServiceResponse.success(payload: pipeline))
64+
end
65+
66+
post_graphql_mutation(mutation, current_user: user)
67+
68+
expect(mutation_response['pipeline']['id']).to eq(pipeline.to_global_id.to_s)
69+
expect(response).to have_gitlab_http_status(:success)
70+
end
71+
end
72+
end
73+
end

0 commit comments

Comments
 (0)