Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-02-24 18:19:04 +00:00
parent c4b4a75c35
commit 94ca431814
52 changed files with 354 additions and 136 deletions

View file

@ -43,5 +43,5 @@ if project_helper.labels_to_add.any?
end
if anything_to_post
markdown("**If needed, you can retry the [`danger-review` job](#{ENV['CI_JOB_URL']}) that generated this comment.**")
markdown("**If needed, you can retry the [🔁 `danger-review` job](#{ENV['CI_JOB_URL']}) that generated this comment.**")
end

View file

@ -1 +1 @@
c35fba1c073deed91d1a1f9f11dd668856841d80
1e442ff0382ed147e7bc4682cd9c278a56163a42

View file

@ -248,11 +248,15 @@ export default {
<gl-badge
v-if="pipeline.flags.merge_train_pipeline"
v-gl-tooltip
:title="__('This is a merge train pipeline')"
:title="
s__(
'Pipeline|This pipeline ran on the contents of this merge request combined with the contents of all other merge requests queued for merging into the target branch.',
)
"
variant="info"
size="sm"
data-testid="pipeline-url-train"
>{{ __('train') }}</gl-badge
>{{ s__('Pipeline|merge train') }}</gl-badge
>
<gl-badge
v-if="pipeline.flags.yaml_errors"
@ -320,14 +324,14 @@ export default {
v-if="pipeline.flags.detached_merge_request_pipeline"
v-gl-tooltip
:title="
__(
'Merge request pipelines are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for merge request pipelines.',
s__(
`Pipeline|This pipeline ran on the contents of this merge request's source branch, not the target branch.`,
)
"
variant="info"
size="sm"
data-testid="pipeline-url-detached"
>{{ __('detached') }}</gl-badge
>{{ s__('Pipeline|merge request') }}</gl-badge
>
<gl-badge
v-if="isInFork"

View file

@ -5,6 +5,9 @@ class Projects::BuildsController < Projects::ApplicationController
feature_category :continuous_integration
urgency :high, [:index, :show]
urgency :low, [:raw]
def index
redirect_to project_jobs_path(project)
end

View file

@ -4,6 +4,8 @@ class Projects::JobsController < Projects::ApplicationController
include SendFileUpload
include ContinueParams
urgency :low, [:index, :show, :trace, :retry, :play, :cancel, :unschedule, :status, :erase, :raw]
before_action :find_job_as_build, except: [:index, :play, :show]
before_action :find_job_as_processable, only: [:play, :show]
before_action :authorize_read_build_trace!, only: [:trace, :raw]

View file

@ -87,7 +87,8 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
:ci_environments_status,
:destroy,
:rebase,
:discussions
:discussions,
:pipelines
]
def index

View file

@ -5,6 +5,10 @@ module Projects
class StagesController < Projects::Pipelines::ApplicationController
before_action :authorize_update_pipeline!
urgency :low, [
:play_manual
]
def play_manual
::Ci::PlayManualStageService
.new(@project, current_user, pipeline: pipeline)

View file

@ -4,6 +4,9 @@ class Projects::PipelinesController < Projects::ApplicationController
include ::Gitlab::Utils::StrongMemoize
include RedisTracking
urgency :default, [:status]
urgency :low, [:index, :new, :builds, :show, :failures, :create, :stage, :retry, :dag, :cancel]
before_action :disable_query_limiting, only: [:create, :retry]
before_action :pipeline, except: [:index, :new, :create, :charts, :config_variables]
before_action :set_pipeline_path, only: [:show]

View file

@ -30,8 +30,17 @@ module Resolvers
return [] if repository.empty?
ref ||= repository.root_ref
validate_ref(ref)
repository.blobs_at(paths.map { |path| [ref, path] })
end
private
def validate_ref(ref)
unless Gitlab::GitRefValidator.validate(ref)
raise Gitlab::Graphql::Errors::ArgumentError, 'Ref is not valid'
end
end
end
end

View file

@ -18,7 +18,7 @@ module TodosHelper
when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you'
when Todo::REVIEW_REQUESTED then 'requested a review of'
when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on"
when Todo::BUILD_FAILED then 'The build failed for'
when Todo::BUILD_FAILED then 'The pipeline failed in'
when Todo::MARKED then 'added a todo for'
when Todo::APPROVAL_REQUIRED then "set #{todo_action_subject(todo)} as an approver for"
when Todo::UNMERGEABLE then 'Could not merge'

View file

@ -7,4 +7,12 @@ class WorkItem < Issue
def noteable_target_type_name
'issue'
end
private
def record_create_action
super
Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter.track_work_item_created_action(author: author)
end
end

View file

@ -31,51 +31,47 @@
%p
= _('You can also upload existing files from your computer using the instructions below.')
.git-empty.js-git-empty
%fieldset
%h5= _('Git global setup')
%pre.bg-light
:preserve
git config --global user.name "#{h git_user_name}"
git config --global user.email "#{h git_user_email}"
%h5= _('Git global setup')
%pre.bg-light
:preserve
git config --global user.name "#{h git_user_name}"
git config --global user.email "#{h git_user_email}"
%fieldset
%h5= _('Create a new repository')
%pre.bg-light
:preserve
git clone #{ content_tag(:span, default_url_to_repo, class: 'js-clone')}
cd #{h @project.path}
git switch -c #{h default_branch_name}
touch README.md
git add README.md
git commit -m "add README"
- if @project.can_current_user_push_to_default_branch?
%span><
git push -u origin #{h default_branch_name }
%h5= _('Create a new repository')
%pre.bg-light
:preserve
git clone #{ content_tag(:span, default_url_to_repo, class: 'js-clone')}
cd #{h @project.path}
git switch -c #{h default_branch_name}
touch README.md
git add README.md
git commit -m "add README"
- if @project.can_current_user_push_to_default_branch?
%span><
git push -u origin #{h default_branch_name }
%fieldset
%h5= _('Push an existing folder')
%pre.bg-light
:preserve
cd existing_folder
git init --initial-branch=#{h default_branch_name}
git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')}
git add .
git commit -m "Initial commit"
- if @project.can_current_user_push_to_default_branch?
%span><
git push -u origin #{h default_branch_name }
%h5= _('Push an existing folder')
%pre.bg-light
:preserve
cd existing_folder
git init --initial-branch=#{h default_branch_name}
git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')}
git add .
git commit -m "Initial commit"
- if @project.can_current_user_push_to_default_branch?
%span><
git push -u origin #{h default_branch_name }
%fieldset
%h5= _('Push an existing Git repository')
%pre.bg-light
:preserve
cd existing_repo
git remote rename origin old-origin
git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')}
- if @project.can_current_user_push_to_default_branch?
%span><
git push -u origin --all
git push -u origin --tags
%h5= _('Push an existing Git repository')
%pre.bg-light
:preserve
cd existing_repo
git remote rename origin old-origin
git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')}
- if @project.can_current_user_push_to_default_branch?
%span><
git push -u origin --all
git push -u origin --tags
- if @project.upload_anchor_data.present?
= render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: project_create_blob_path(@project, default_branch_name), ref: default_branch_name, method: :post

View file

@ -27,7 +27,7 @@
- if @pipeline.latest?
= gl_badge_tag s_('Pipelines|latest'), { variant: :success, size: :sm }, { class: 'js-pipeline-url-latest has-tooltip', title: _("Latest pipeline for the most recent commit on this branch") }
- if @pipeline.merge_train_pipeline?
= gl_badge_tag s_('Pipelines|train'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-train has-tooltip', title: _("This is a merge train pipeline") }
= gl_badge_tag s_('Pipelines|merge train'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-train has-tooltip', title: s_("Pipelines|This pipeline ran on the contents of this merge request combined with the contents of all other merge requests queued for merging into the target branch.") }
- if @pipeline.has_yaml_errors?
= gl_badge_tag s_('Pipelines|yaml invalid'), { variant: :danger, size: :sm }, { class: 'js-pipeline-url-yaml has-tooltip', title: @pipeline.yaml_errors }
- if @pipeline.failure_reason?
@ -38,7 +38,7 @@
- popover_content_text = _('Learn more about Auto DevOps')
= gl_badge_tag s_('Pipelines|Auto DevOps'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-autodevops', href: "#", tabindex: "0", role: "button", data: { container: 'body', toggle: 'popover', placement: 'top', html: 'true', triggers: 'focus', title: "<div class='gl-font-weight-normal gl-line-height-normal'>#{popover_title_text}</div>", content: "<a href='#{popover_content_url}' target='_blank' rel='noopener noreferrer nofollow'>#{popover_content_text}</a>" } }
- if @pipeline.detached_merge_request_pipeline?
= gl_badge_tag s_('Pipelines|detached'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-mergerequest has-tooltip', title: _('Merge request pipelines are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for merge request pipelines.') }
= gl_badge_tag s_('Pipelines|merge request'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-mergerequest has-tooltip', title: s_("Pipelines|This pipeline ran on the contents of this merge request's source branch, not the target branch.") }
- if @pipeline.stuck?
= gl_badge_tag s_('Pipelines|stuck'), { variant: :warning, size: :sm }, { class: 'js-pipeline-url-stuck has-tooltip' }

View file

@ -0,0 +1,25 @@
---
key_path: redis_hll_counters.work_items.users_creating_work_items_monthly
description: Unique users creating work items
product_category: team planning
product_section: dev
product_stage: plan
product_group: group::project management
value_type: number
status: active
milestone: '14.9'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81201
time_frame: 28d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
options:
events:
- users_creating_work_items
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View file

@ -0,0 +1,25 @@
---
key_path: redis_hll_counters.work_items.users_creating_work_items_weekly
description: Unique users creating work items
product_category: team planning
product_section: dev
product_stage: plan
product_group: group::project management
value_type: number
status: active
milestone: '14.9'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81201
time_frame: 7d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
options:
events:
- users_creating_work_items
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
class AsyncBuildTraceExpireAtIndex < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'tmp_index_ci_job_artifacts_on_id_where_trace_and_expire_at'
TIMESTAMPS = "'2021-04-22 00:00:00', '2021-05-22 00:00:00', '2021-06-22 00:00:00', '2022-01-22 00:00:00', '2022-02-22 00:00:00', '2022-03-22 00:00:00', '2022-04-22 00:00:00'"
def up
prepare_async_index :ci_job_artifacts, :id, where: "file_type = 3 AND expire_at IN (#{TIMESTAMPS})", name: INDEX_NAME
end
def down
unprepare_async_index :ci_builds, :id, name: INDEX_NAME
end
end

View file

@ -0,0 +1 @@
74b4d572118b7f5da0a80722601a4757ce47ccbdae1af1e84b2304343477d634

View file

@ -13,6 +13,7 @@ ignorecase: true
swap:
codequality: code quality
Customer [Pp]ortal: Customers Portal
disallow: prevent
frontmatter: front matter
GitLabber: GitLab team member
GitLabbers: GitLab team members

View file

@ -26,7 +26,7 @@ Features behind flags can be gradually rolled out, typically:
1. The feature becomes enabled by default.
1. The feature flag is removed.
These features can be enabled and disabled to allow or disallow users to use
These features can be enabled and disabled to allow or prevent users from using
them. It can be done by GitLab administrators with access to GitLab Rails
console.

View file

@ -7,7 +7,8 @@ type: reference, api
# Group wikis API **(PREMIUM)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/212199) in GitLab 13.5.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/212199) in GitLab 13.5.
> - The `encoding` field was [added](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81150) in GitLab 14.9.
The [group wikis](../user/project/wiki/group.md) API is available only in APIv4.
An API for [project wikis](wikis.md) is also available.
@ -37,18 +38,21 @@ Example response:
"content" : "Here is an instruction how to deploy this project.",
"format" : "markdown",
"slug" : "deploy",
"title" : "deploy"
"title" : "deploy",
"encoding": "UTF-8"
},
{
"content" : "Our development process is described here.",
"format" : "markdown",
"slug" : "development",
"title" : "development"
"title" : "development",
"encoding": "UTF-8"
},{
"content" : "* [Deploy](deploy)\n* [Development](development)",
"format" : "markdown",
"slug" : "home",
"title" : "home"
"title" : "home",
"encoding": "UTF-8"
}
]
```
@ -77,7 +81,8 @@ Example response:
"content" : "home page",
"format" : "markdown",
"slug" : "home",
"title" : "home"
"title" : "home",
"encoding": "UTF-8"
}
```
@ -109,7 +114,8 @@ Example response:
"content" : "Hello world",
"format" : "markdown",
"slug" : "Hello",
"title" : "Hello"
"title" : "Hello",
"encoding": "UTF-8"
}
```
@ -142,7 +148,8 @@ Example response:
"content" : "documentation",
"format" : "markdown",
"slug" : "Docs",
"title" : "Docs"
"title" : "Docs",
"encoding": "UTF-8"
}
```

View file

@ -58,9 +58,9 @@ POST /projects/:id/approvals
| `id` | integer or string | yes | The ID or [URL-encoded path of a project](index.md#namespaced-path-encoding) |
| `approvals_before_merge` | integer | no | How many approvals are required before an MR can be merged. Deprecated in 12.0 in favor of Approval Rules API. |
| `reset_approvals_on_push` | boolean | no | Reset approvals on a new push |
| `disable_overriding_approvers_per_merge_request` | boolean | no | Allow/Disallow overriding approvers per MR |
| `merge_requests_author_approval` | boolean | no | Allow/Disallow authors from self approving merge requests; `true` means authors can self approve |
| `merge_requests_disable_committers_approval` | boolean | no | Allow/Disallow committers from self approving merge requests |
| `disable_overriding_approvers_per_merge_request` | boolean | no | Allow or prevent overriding approvers per MR |
| `merge_requests_author_approval` | boolean | no | Allow or prevent authors from self approving merge requests; `true` means authors can self approve |
| `merge_requests_disable_committers_approval` | boolean | no | Allow or prevent committers from self approving merge requests |
| `require_password_to_approve` | boolean | no | Require approver to enter a password to authenticate before adding the approval |
```json

View file

@ -775,8 +775,8 @@ the `approvals_before_merge` parameter:
### Single merge request response notes
- The `merge_status` field may hold one of the following values:
- `unchecked`: We have not checked this yet.
- `checking`: We are currently checking if the merge request can be merged.
- `unchecked`: This merge request has not yet been checked.
- `checking`: This merge request is currently being checked to see if it can be merged.
- `can_be_merged`: This merge request can be merged without conflict.
- `cannot_be_merged`: There are merge conflicts between the source and target branches.
- `cannot_be_merged_recheck`: Currently unchecked. Before the current changes, there were conflicts.

View file

@ -6,6 +6,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Project wikis API **(FREE)**
> The `encoding` field was [added](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81150) in GitLab 14.9.
The project [wikis](../user/project/wiki/index.md) API is available only in APIv4.
An API for [group wikis](group_wikis.md) is also available.
@ -34,18 +36,21 @@ Example response:
"content" : "Here is an instruction how to deploy this project.",
"format" : "markdown",
"slug" : "deploy",
"title" : "deploy"
"title" : "deploy",
"encoding": "UTF-8"
},
{
"content" : "Our development process is described here.",
"format" : "markdown",
"slug" : "development",
"title" : "development"
"title" : "development",
"encoding": "UTF-8"
},{
"content" : "* [Deploy](deploy)\n* [Development](development)",
"format" : "markdown",
"slug" : "home",
"title" : "home"
"title" : "home",
"encoding": "UTF-8"
}
]
```
@ -74,7 +79,8 @@ Example response:
"content" : "home page",
"format" : "markdown",
"slug" : "home",
"title" : "home"
"title" : "home",
"encoding": "UTF-8"
}
```
@ -105,7 +111,8 @@ Example response:
"content" : "Hello world",
"format" : "markdown",
"slug" : "Hello",
"title" : "Hello"
"title" : "Hello",
"encoding": "UTF-8"
}
```
@ -137,7 +144,8 @@ Example response:
"content" : "documentation",
"format" : "markdown",
"slug" : "Docs",
"title" : "Docs"
"title" : "Docs",
"encoding": "UTF-8"
}
```

View file

@ -252,6 +252,11 @@ Do not use **Developer permissions**. A user who is assigned the Developer role
See [the Microsoft style guide](https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/d/disable-disabled) for guidance on **disable**.
Use **inactive** or **off** instead. ([Vale](../testing.md#vale) rule: [`InclusionAbleism.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/.vale/gitlab/InclusionAbleism.yml))
## disallow
Use **prevent** instead of **disallow**. ([Vale](../testing.md#vale) rule: [`Substitutions.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/.vale/gitlab/Substitutions.yml))
## dropdown list
Use **dropdown list** to refer to the UI element. Do not use **dropdown** without **list** after it.

View file

@ -122,7 +122,7 @@ Large parts of ActiveRecord's persistence API are built around the notion of cal
of these callbacks fire in response to model life cycle events such as `save` or `create`.
These callbacks cannot be used with bulk insertions, since they are meant to be called for
every instance that is saved or created. Since these events do not fire when
records are inserted in bulk, we currently disallow their use.
records are inserted in bulk, we currently prevent their use.
The specifics around which callbacks are explicitly allowed are defined in
[`BulkInsertSafe`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/concerns/bulk_insert_safe.rb).

View file

@ -136,7 +136,7 @@ Mitigation strategies include:
1. Not allowing redirects to attacker controller resources:
[`Kubeclient::KubeClient`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/kubernetes/kube_client.rb#)
can be configured to disallow any redirects by passing in
can be configured to prevent any redirects by passing in
`http_max_redirects: 0` as an option.
1. Not exposing error messages: by doing so, we
prevent attackers from triggering errors to expose results from

View file

@ -520,7 +520,7 @@ To install and run Snowplow Micro, complete these steps to modify the
### Troubleshoot
To control content security policy warnings when using an external host, modify `config/gitlab.yml`
to allow or disallow them. To allow them, add the relevant host for `connect_src`. For example, for
to allow or prevent them. To allow them, add the relevant host for `connect_src`. For example, for
`https://snowplow.trx.gitlab.net`:
```yaml

View file

@ -662,7 +662,7 @@ Sidekiq processes](../administration/operations/extra_sidekiq_processes.md).
```
You can also use the `gitlab:elastic:clear_index_status` Rake task to force the
indexer to "forget" all progress, so it will retry the indexing process from the
indexer to "forget" all progress, so it retries the indexing process from the
start.
1. Personal snippets are not associated with a project and need to be indexed separately:

View file

@ -74,7 +74,7 @@ The following are important notes about 2FA:
2FA enabled, 2FA is **not** required for those individually added members.
- If there are multiple 2FA requirements (for example, group + all users, or multiple
groups) the shortest grace period is used.
- It is possible to disallow subgroups from setting up their own 2FA requirements:
- It is possible to prevent subgroups from setting up their own 2FA requirements:
1. Go to the top-level group's **Settings > General**.
1. Expand the **Permissions and group features** section.
1. Uncheck the **Allow subgroups to set up their own two-factor authentication rule** field.

View file

@ -65,7 +65,7 @@ This restriction also applies to projects forked from or to those groups.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/34648) in GitLab 12.9.
Groups with group-managed accounts can disallow forking of projects to destinations outside the group.
Groups with group-managed accounts can prevent forking of projects to destinations outside the group.
To do so, enable the "Prohibit outer forks" option in **Settings > SAML SSO**.
When enabled **at the parent group level**, projects within the group can be forked
only to other destinations within the group (including its subgroups).

View file

@ -38,7 +38,7 @@ module API
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
get ':id/jobs', feature_category: :continuous_integration do
get ':id/jobs', urgency: :low, feature_category: :continuous_integration do
authorize_read_builds!
builds = user_project.builds.order('id DESC')
@ -55,7 +55,7 @@ module API
params do
requires :job_id, type: Integer, desc: 'The ID of a job'
end
get ':id/jobs/:job_id', feature_category: :continuous_integration do
get ':id/jobs/:job_id', urgency: :low, feature_category: :continuous_integration do
authorize_read_builds!
build = find_build!(params[:job_id])
@ -70,7 +70,7 @@ module API
params do
requires :job_id, type: Integer, desc: 'The ID of a job'
end
get ':id/jobs/:job_id/trace', feature_category: :continuous_integration do
get ':id/jobs/:job_id/trace', urgency: :low, feature_category: :continuous_integration do
authorize_read_builds!
build = find_build!(params[:job_id])
@ -92,7 +92,7 @@ module API
params do
requires :job_id, type: Integer, desc: 'The ID of a job'
end
post ':id/jobs/:job_id/cancel', feature_category: :continuous_integration do
post ':id/jobs/:job_id/cancel', urgency: :low, feature_category: :continuous_integration do
authorize_update_builds!
build = find_build!(params[:job_id])
@ -109,7 +109,7 @@ module API
params do
requires :job_id, type: Integer, desc: 'The ID of a build'
end
post ':id/jobs/:job_id/retry', feature_category: :continuous_integration do
post ':id/jobs/:job_id/retry', urgency: :low, feature_category: :continuous_integration do
authorize_update_builds!
build = find_build!(params[:job_id])
@ -127,7 +127,7 @@ module API
params do
requires :job_id, type: Integer, desc: 'The ID of a build'
end
post ':id/jobs/:job_id/erase', feature_category: :continuous_integration do
post ':id/jobs/:job_id/erase', urgency: :low, feature_category: :continuous_integration do
authorize_update_builds!
build = find_build!(params[:job_id])
@ -146,7 +146,7 @@ module API
requires :job_id, type: Integer, desc: 'The ID of a Job'
end
post ":id/jobs/:job_id/play", feature_category: :continuous_integration do
post ':id/jobs/:job_id/play', urgency: :low, feature_category: :continuous_integration do
authorize_read_builds!
job = find_job!(params[:job_id])
@ -168,11 +168,11 @@ module API
end
resource :job do
desc 'Get current project using job token' do
desc 'Get current job using job token' do
success Entities::Ci::Job
end
route_setting :authentication, job_token_allowed: true
get '', feature_category: :continuous_integration do
get '', feature_category: :continuous_integration, urgency: :low do
validate_current_authenticated_job
present current_authenticated_job, with: Entities::Ci::Job

View file

@ -123,7 +123,7 @@ module API
use :pagination
end
get ':id/pipelines/:pipeline_id/jobs', feature_category: :continuous_integration do
get ':id/pipelines/:pipeline_id/jobs', urgency: :low, feature_category: :continuous_integration do
authorize!(:read_pipeline, user_project)
pipeline = user_project.all_pipelines.find(params[:pipeline_id])

View file

@ -131,7 +131,7 @@ module API
formatter :build_json, ->(object, _) { object }
parser :build_json, ::Grape::Parser::Json
post '/request', feature_category: :continuous_integration do
post '/request', urgency: :low, feature_category: :continuous_integration do
authenticate_runner!
unless current_runner.active?
@ -185,7 +185,7 @@ module API
end
optional :exit_code, type: Integer, desc: %q(Job's exit code)
end
put '/:id', feature_category: :continuous_integration do
put '/:id', urgency: :low, feature_category: :continuous_integration do
job = authenticate_job!(heartbeat_runner: true)
Gitlab::Metrics.add_event(:update_build)
@ -212,7 +212,7 @@ module API
requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token)
end
patch '/:id/trace', feature_category: :continuous_integration do
patch '/:id/trace', urgency: :default, feature_category: :continuous_integration do
job = authenticate_job!(heartbeat_runner: true)
error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range')

View file

@ -4,6 +4,10 @@ module API
module Entities
class WikiPage < WikiPageBasic
expose :content
expose :encoding do |wiki_page|
wiki_page.content.encoding.name
end
end
end
end

View file

@ -33,6 +33,10 @@ module Gitlab
def fetch_local_content
context.project.repository.blob_data_at(context.sha, location)
rescue GRPC::InvalidArgument
errors.push("Sha #{context.sha} is not valid!")
nil
end
override :expand_context_attrs

View file

@ -4,3 +4,8 @@
redis_slot: users
aggregation: weekly
feature_flag: track_work_items_activity
- name: users_creating_work_items
category: work_items
redis_slot: users
aggregation: weekly
feature_flag: track_work_items_activity

View file

@ -3,9 +3,14 @@
module Gitlab
module UsageDataCounters
module WorkItemActivityUniqueCounter
WORK_ITEM_CREATED = 'users_creating_work_items'
WORK_ITEM_TITLE_CHANGED = 'users_updating_work_item_title'
class << self
def track_work_item_created_action(author:)
track_unique_action(WORK_ITEM_CREATED, author)
end
def track_work_item_title_changed_action(author:)
track_unique_action(WORK_ITEM_TITLE_CHANGED, author)
end

View file

@ -22972,9 +22972,6 @@ msgstr ""
msgid "Merge request not merged"
msgstr ""
msgid "Merge request pipelines are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for merge request pipelines."
msgstr ""
msgid "Merge request reports"
msgstr ""
@ -27017,6 +27014,12 @@ msgstr ""
msgid "Pipelines|This is a child pipeline within the parent pipeline"
msgstr ""
msgid "Pipelines|This pipeline ran on the contents of this merge request combined with the contents of all other merge requests queued for merging into the target branch."
msgstr ""
msgid "Pipelines|This pipeline ran on the contents of this merge request's source branch, not the target branch."
msgstr ""
msgid "Pipelines|This pipeline will run code originating from a forked project merge request. This means that the code can potentially have security considerations like exposing CI variables."
msgstr ""
@ -27059,9 +27062,6 @@ msgstr ""
msgid "Pipelines|Your changes have been successfully committed. Now redirecting to the new merge request page."
msgstr ""
msgid "Pipelines|detached"
msgstr ""
msgid "Pipelines|error"
msgstr ""
@ -27071,10 +27071,13 @@ msgstr ""
msgid "Pipelines|latest"
msgstr ""
msgid "Pipelines|stuck"
msgid "Pipelines|merge request"
msgstr ""
msgid "Pipelines|train"
msgid "Pipelines|merge train"
msgstr ""
msgid "Pipelines|stuck"
msgstr ""
msgid "Pipelines|yaml invalid"
@ -27206,6 +27209,12 @@ msgstr ""
msgid "Pipeline|This change will not change the overall test coverage if merged."
msgstr ""
msgid "Pipeline|This pipeline ran on the contents of this merge request combined with the contents of all other merge requests queued for merging into the target branch."
msgstr ""
msgid "Pipeline|This pipeline ran on the contents of this merge request's source branch, not the target branch."
msgstr ""
msgid "Pipeline|Trigger author"
msgstr ""
@ -27230,6 +27239,12 @@ msgstr ""
msgid "Pipeline|for"
msgstr ""
msgid "Pipeline|merge request"
msgstr ""
msgid "Pipeline|merge train"
msgstr ""
msgid "Pipeline|on"
msgstr ""
@ -37452,9 +37467,6 @@ msgstr ""
msgid "This is a list of devices that have logged into your account. Revoke any sessions that you do not recognize."
msgstr ""
msgid "This is a merge train pipeline"
msgstr ""
msgid "This is a private email address %{helpIcon} generated just for you. Anyone who has it can create issues or merge requests as if they were you. If that happens, %{resetLinkStart}reset this token%{resetLinkEnd}."
msgstr ""
@ -43290,9 +43302,6 @@ msgstr ""
msgid "design"
msgstr ""
msgid "detached"
msgstr ""
msgid "disabled"
msgstr ""
@ -44448,9 +44457,6 @@ msgstr ""
msgid "toggle collapse"
msgstr ""
msgid "train"
msgstr ""
msgid "triggered"
msgstr ""

View file

@ -178,7 +178,7 @@ RSpec.describe 'Dashboard > User filters todos', :js do
review_requested: ' requested a review of ',
mentioned: ' mentioned ',
marked: ' added a todo for ',
build_failed: ' build failed for '
build_failed: ' pipeline failed in '
}
action_name_text = action_names.delete(action_name)

View file

@ -400,7 +400,7 @@ RSpec.describe 'Dashboard Todos' do
end
it 'shows the todo' do
expect(page).to have_content 'The build failed for merge request'
expect(page).to have_content 'The pipeline failed in merge request'
end
it 'links to the pipelines for the merge request' do

View file

@ -25,6 +25,8 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
}
end
let(:expected_detached_mr_tag) {'merge request'}
before do
stub_application_setting(auto_devops_enabled: false)
stub_ci_pipeline_yaml_file(YAML.dump(config))
@ -118,16 +120,16 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
it 'sees detached tag for detached merge request pipelines' do
page.within('.ci-table') do
expect(all('.pipeline-tags')[0])
.to have_content("detached")
.to have_content(expected_detached_mr_tag)
expect(all('.pipeline-tags')[1])
.to have_content("detached")
.to have_content(expected_detached_mr_tag)
expect(all('.pipeline-tags')[2])
.not_to have_content("detached")
.not_to have_content(expected_detached_mr_tag)
expect(all('.pipeline-tags')[3])
.not_to have_content("detached")
.not_to have_content(expected_detached_mr_tag)
end
end
@ -312,16 +314,16 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
it 'sees detached tag for detached merge request pipelines' do
page.within('.ci-table') do
expect(all('.pipeline-tags')[0])
.to have_content("detached")
.to have_content(expected_detached_mr_tag)
expect(all('.pipeline-tags')[1])
.to have_content("detached")
.to have_content(expected_detached_mr_tag)
expect(all('.pipeline-tags')[2])
.not_to have_content("detached")
.not_to have_content(expected_detached_mr_tag)
expect(all('.pipeline-tags')[3])
.not_to have_content("detached")
.not_to have_content(expected_detached_mr_tag)
end
end

View file

@ -186,7 +186,7 @@ RSpec.describe 'Merge request > User sees pipelines', :js do
page.within(first('.commit')) do
page.within('.pipeline-tags') do
expect(page.find('[data-testid="pipeline-url-link"]')[:href]).to include(expected_project.full_path)
expect(page).to have_content('detached')
expect(page).to have_content('merge request')
end
page.within('.pipeline-triggerer') do
expect(page).to have_link(href: user_path(actor))

View file

@ -1413,7 +1413,7 @@ RSpec.describe 'Pipeline', :js do
it 'contains badge that indicates detached merge request pipeline' do
page.within(all('.well-segment')[1]) do
expect(page).to have_content 'detached'
expect(page).to have_content 'merge request'
end
end
end

View file

@ -7,6 +7,7 @@ RSpec.describe 'Pipelines', :js do
include Spec::Support::Helpers::ModalHelpers
let(:project) { create(:project) }
let(:expected_detached_mr_tag) {'merge request'}
context 'when user is logged in' do
let(:user) { create(:user) }
@ -181,7 +182,7 @@ RSpec.describe 'Pipelines', :js do
shared_examples_for 'detached merge request pipeline' do
it 'shows pipeline information without pipeline ref', :sidekiq_might_not_need_inline do
within '.pipeline-tags' do
expect(page).to have_content('detached')
expect(page).to have_content(expected_detached_mr_tag)
end
within '.branch-commit' do
@ -225,7 +226,7 @@ RSpec.describe 'Pipelines', :js do
shared_examples_for 'detached merge request pipeline' do
it 'shows pipeline information without pipeline ref', :sidekiq_might_not_need_inline do
within '.pipeline-tags' do
expect(page).to have_content('detached')
expect(page).to have_content(expected_detached_mr_tag)
expect(page).to have_link(merge_request.iid,
href: project_merge_request_path(project, merge_request))
@ -266,7 +267,7 @@ RSpec.describe 'Pipelines', :js do
shared_examples_for 'Correct merge request pipeline information' do
it 'does not show detached tag for the pipeline, and shows the link of the merge request, and does not show the ref of the pipeline', :sidekiq_might_not_need_inline do
within '.pipeline-tags' do
expect(page).not_to have_content('detached')
expect(page).not_to have_content(expected_detached_mr_tag)
end
within '.branch-commit' do
@ -311,7 +312,7 @@ RSpec.describe 'Pipelines', :js do
shared_examples_for 'Correct merge request pipeline information' do
it 'does not show detached tag for the pipeline, and shows the link of the merge request, and does not show the ref of the pipeline', :sidekiq_might_not_need_inline do
within '.pipeline-tags' do
expect(page).not_to have_content('detached')
expect(page).not_to have_content(expected_detached_mr_tag)
expect(page).to have_link(merge_request.iid,
href: project_merge_request_path(project, merge_request))

View file

@ -132,7 +132,7 @@ describe('Pipeline Url Component', () => {
...detachedMRPipeline,
});
expect(findDetachedTag().text()).toContain('detached');
expect(findDetachedTag().text()).toBe('merge request');
});
it('should render error badge when pipeline has a failure reason set', () => {
@ -180,7 +180,7 @@ describe('Pipeline Url Component', () => {
...mergeTrainPipeline,
});
expect(findTrainTag().text()).toContain('train');
expect(findTrainTag().text()).toBe('merge train');
});
it('should not render the train badge when the pipeline is not a merge train pipeline', () => {

View file

@ -68,6 +68,28 @@ RSpec.describe Resolvers::BlobsResolver do
)
end
end
context 'when specifying an invalid ref' do
let(:ref) { 'ma:in' }
it 'raises an ArgumentError' do
expect { resolve_blobs }.to raise_error(
Gitlab::Graphql::Errors::ArgumentError,
'Ref is not valid'
)
end
end
context 'when passing an empty ref' do
let(:ref) { '' }
it 'raises an ArgumentError' do
expect { resolve_blobs }.to raise_error(
Gitlab::Graphql::Errors::ArgumentError,
'Ref is not valid'
)
end
end
end
end
end

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::Entities::WikiPage do
let_it_be_with_reload(:wiki_page) { create(:wiki_page) }
let(:entity) { described_class.new(wiki_page) }
it 'returns the proper encoding for the wiki page content' do
expect(entity.as_json[:encoding]).to eq 'UTF-8'
wiki_page.update_attributes(content: 'new_content'.encode('ISO-8859-1')) # rubocop:disable Rails/ActiveRecordAliases, Rails/SaveBang
expect(entity.as_json[:encoding]).to eq 'ISO-8859-1'
end
end

View file

@ -81,6 +81,16 @@ RSpec.describe Gitlab::Ci::Config::External::File::Local do
expect(local_file.valid?).to be_falsy
end
end
context 'when the given sha is not valid' do
let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' }
let(:sha) { ':' }
it 'returns false and adds an error message stating that included file does not exist' do
expect(local_file).not_to be_valid
expect(local_file.errors).to include("Sha #{sha} is not valid!")
end
end
end
describe '#content' do

View file

@ -17,16 +17,12 @@ RSpec.describe Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter, :clean_
end
end
describe '.track_work_item_title_changed_action' do
subject(:track_event) { described_class.track_work_item_title_changed_action(author: user) }
let(:event_name) { described_class::WORK_ITEM_TITLE_CHANGED }
shared_examples 'work item unique counter' do
context 'when track_work_items_activity FF is enabled' do
it 'tracks a unique event only once' do
expect { 3.times { track_event } }.to change {
Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(
event_names: described_class::WORK_ITEM_TITLE_CHANGED,
event_names: event_name,
start_date: 2.weeks.ago,
end_date: 2.weeks.from_now
)
@ -48,4 +44,20 @@ RSpec.describe Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter, :clean_
it_behaves_like 'counter that does not track the event'
end
end
describe '.track_work_item_created_action' do
subject(:track_event) { described_class.track_work_item_created_action(author: user) }
let(:event_name) { described_class::WORK_ITEM_CREATED }
it_behaves_like 'work item unique counter'
end
describe '.track_work_item_title_changed_action' do
subject(:track_event) { described_class.track_work_item_title_changed_action(author: user) }
let(:event_name) { described_class::WORK_ITEM_TITLE_CHANGED }
it_behaves_like 'work item unique counter'
end
end

View file

@ -10,4 +10,16 @@ RSpec.describe WorkItem do
expect(work_item.noteable_target_type_name).to eq('issue')
end
end
describe 'callbacks' do
describe 'record_create_action' do
it 'records the creation action after saving' do
expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter).to receive(:track_work_item_created_action)
# During the work item transition we also want to track work items as issues
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_created_action)
create(:work_item)
end
end
end
end

View file

@ -31,7 +31,7 @@ RSpec.describe API::Wikis do
let(:project_wiki) { create(:project_wiki, project: project, user: user) }
let(:payload) { { content: 'content', format: 'rdoc', title: 'title' } }
let(:expected_keys_with_content) { %w(content format slug title) }
let(:expected_keys_with_content) { %w(content format slug title encoding) }
let(:expected_keys_without_content) { %w(format slug title) }
let(:wiki) { project_wiki }

View file

@ -46,11 +46,12 @@ end
RSpec.shared_examples_for 'wikis API returns wiki page' do
it 'returns the wiki page' do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(4)
expect(json_response.size).to eq(5)
expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(page.content)
expect(json_response['slug']).to eq(page.slug)
expect(json_response['title']).to eq(page.title)
expect(json_response['encoding']).to eq('UTF-8')
end
end
@ -59,12 +60,13 @@ RSpec.shared_examples_for 'wikis API creates wiki page' do
post(api(url, user), params: payload)
expect(response).to have_gitlab_http_status(:created)
expect(json_response.size).to eq(4)
expect(json_response.size).to eq(5)
expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(payload[:content])
expect(json_response['slug']).to eq(payload[:title].tr(' ', '-'))
expect(json_response['title']).to eq(payload[:title])
expect(json_response['rdoc']).to eq(payload[:rdoc])
expect(json_response['encoding']).to eq('UTF-8')
end
[:title, :content].each do |part|
@ -85,7 +87,7 @@ RSpec.shared_examples_for 'wikis API updates wiki page' do
put(api(url, user), params: payload)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(4)
expect(json_response.size).to eq(5)
expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(payload[:content])
expect(json_response['slug']).to eq(payload[:title].tr(' ', '-'))