Commit 79040c61 authored by 🤖 GitLab Bot 🤖's avatar 🤖 GitLab Bot 🤖

Add latest changes from gitlab-org/[email protected]

parent 340f15b4
......@@ -43,7 +43,14 @@ https://about.gitlab.com/handbook/engineering/ux/ux-research-training/user-story
### Permissions and Security
<!-- What permissions are required to perform the described actions? Are they consistent with the existing permissions as documented for users, groups, and projects as appropriate? Is the proposed behavior consistent between the UI, API, and other access methods (e.g. email replies)?-->
<!-- What permissions are required to perform the described actions? Are they consistent with the existing permissions as documented for users, groups, and projects as appropriate? Is the proposed behavior consistent between the UI, API, and other access methods (e.g. email replies)?
Consider adding checkboxes and expectations of users with certain levels of membership https://docs.gitlab.com/ee/user/permissions.html
* [ ] Add expected impact to members with no access (0)
* [ ] Add expected impact to Guest (10) members
* [ ] Add expected impact to Reporter (20) members
* [ ] Add expected impact to Developer (30) members
* [ ] Add expected impact to Maintainer (40) members
* [ ] Add expected impact to Owner (50) members -->
### Documentation
......
......@@ -405,6 +405,7 @@ class ProjectsController < Projects::ApplicationController
],
project_setting_attributes: %i[
show_default_award_emojis
squash_option
]
]
end
......
......@@ -118,7 +118,7 @@ module MergeRequestsHelper
auto_merge_strategy: AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS,
should_remove_source_branch: true,
sha: merge_request.diff_head_sha,
squash: merge_request.squash
squash: merge_request.squash_on_merge?
}
end
......
......@@ -1144,6 +1144,13 @@ class MergeRequest < ApplicationRecord
end
end
def squash_on_merge?
return true if target_project.squash_always?
return false if target_project.squash_never?
squash?
end
def has_ci?
return false if has_no_commits?
......
......@@ -363,6 +363,7 @@ class Project < ApplicationRecord
to: :project_setting, allow_nil: true
delegate :scheduled?, :started?, :in_progress?, :failed?, :finished?,
prefix: :import, to: :import_state, allow_nil: true
delegate :squash_always?, :squash_never?, :squash_enabled_by_default?, :squash_readonly?, to: :project_setting
delegate :no_import?, to: :import_state, allow_nil: true
delegate :name, to: :owner, allow_nil: true, prefix: true
delegate :members, to: :team, prefix: true
......
......@@ -3,7 +3,22 @@
class ProjectSetting < ApplicationRecord
belongs_to :project, inverse_of: :project_setting
enum squash_option: {
never: 0,
always: 1,
default_on: 2,
default_off: 3
}, _prefix: 'squash'
self.primary_key = :project_id
def squash_enabled_by_default?
%w[always default_on].include?(squash_option)
end
def squash_readonly?
%w[always never].include?(squash_option)
end
end
ProjectSetting.prepend_if_ee('EE::ProjectSetting')
......@@ -74,6 +74,18 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity
diffs_project_merge_request_path(merge_request.project, merge_request)
end
expose :squash_enabled_by_default do |merge_request|
presenter(merge_request).project.squash_enabled_by_default?
end
expose :squash_readonly do |merge_request|
presenter(merge_request).project.squash_readonly?
end
expose :squash_on_merge do |merge_request|
presenter(merge_request).squash_on_merge?
end
private
delegate :current_user, to: :request
......
......@@ -145,6 +145,18 @@ class MergeRequestPollWidgetEntity < Grape::Entity
presenter(merge_request).revert_in_fork_path
end
expose :squash_enabled_by_default do |merge_request|
presenter(merge_request).project.squash_enabled_by_default?
end
expose :squash_readonly do |merge_request|
presenter(merge_request).project.squash_readonly?
end
expose :squash_on_merge do |merge_request|
presenter(merge_request).squash_on_merge?
end
private
delegate :current_user, to: :request
......
......@@ -16,7 +16,7 @@ module MergeRequests
merge_request.target_branch,
merge_request: merge_request)
if merge_request.squash
if merge_request.squash_on_merge?
merge_request.update_column(:squash_commit_sha, merge_request.in_progress_merge_commit_sha)
end
......
......@@ -20,7 +20,7 @@ module MergeRequests
def source
strong_memoize(:source) do
if merge_request.squash
if merge_request.squash_on_merge?
squash_sha!
else
merge_request.diff_head_sha
......
......@@ -56,6 +56,8 @@ module MergeRequests
'Only fast-forward merge is allowed for your project. Please update your source branch'
elsif !@merge_request.mergeable?
'Merge request is not mergeable'
elsif !@merge_request.squash && project.squash_always?
'This project requires squashing commits when merge requests are accepted.'
end
raise_error(error) if error
......
......@@ -11,11 +11,14 @@ module MergeRequests
return success(squash_sha: merge_request.diff_head_sha)
end
return error(s_('MergeRequests|This project does not allow squashing commits when merge requests are accepted.')) if squash_forbidden?
if squash_in_progress?
return error(s_('MergeRequests|Squash task canceled: another squash is already in progress.'))
end
squash! || error(s_('MergeRequests|Failed to squash. Should be done manually.'))
rescue SquashInProgressError
error(s_('MergeRequests|An error occurred while checking whether another squash is in progress.'))
end
......@@ -40,6 +43,10 @@ module MergeRequests
raise SquashInProgressError, e.message
end
def squash_forbidden?
target_project.squash_never?
end
def repository
target_project.repository
end
......
---
title: Add squash commits options as a project setting.
merge_request: 33099
author:
type: added
---
title: Add snippets_size to Group entity
merge_request: 35585
author:
type: changed
---
title: Avoid grouping statement timeouts in Sentry
merge_request: 35479
author:
type: other
# frozen_string_literal: true
class AddSquashOptionToProject < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :project_settings, :squash_option, :integer, default: 3, limit: 2
end
end
......@@ -14163,6 +14163,7 @@ CREATE TABLE public.project_settings (
push_rule_id bigint,
show_default_award_emojis boolean DEFAULT true,
allow_merge_on_skipped_pipeline boolean,
squash_option smallint DEFAULT 3,
CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL))
);
......@@ -23417,6 +23418,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200526153844
20200526164946
20200526164947
20200526193555
20200526231421
20200527092027
20200527094322
......
---
# Warning: gitlab.FutureTense
# Suggestion: gitlab.FutureTense
#
# Checks for use of future tense in sentences. Present tense is preferred as
# much as possible.
......
......@@ -94,7 +94,8 @@ GET /groups?statistics=true
"wiki_size" : 100,
"lfs_objects_size" : 123,
"job_artifacts_size" : 57,
"packages_size": 0
"packages_size": 0,
"snippets_size" : 50,
}
}
]
......
This diff is collapsed.
......@@ -26,8 +26,9 @@ The following resources will help you get started with Git:
- [Git Basics](https://git-scm.com/book/en/v2/Getting-Started-Git-Basics)
- [Git on the Server - GitLab](https://git-scm.com/book/en/v2/Git-on-the-Server-GitLab)
- [How to install Git](how_to_install_git/index.md)
- [Git terminology](../../gitlab-basics/start-using-git.md#git-terminology)
- [Start using Git on the command line](../../gitlab-basics/start-using-git.md)
- [Command line file editing basic commands](../../gitlab-basics/command-line-commands.md)
- [Edit files through the command line](../../gitlab-basics/command-line-commands.md)
- [GitLab Git Cheat Sheet (download)](https://about.gitlab.com/images/press/git-cheat-sheet.pdf)
- Commits:
- [Revert a commit](../../user/project/merge_requests/revert_changes.md#reverting-a-commit)
......
......@@ -186,6 +186,7 @@ The following variables are used for configuring specific analyzers (used for a
| `DS_PIP_VERSION` | `gemnasium-python` | | Force the install of a specific pip version (example: `"19.3"`), otherwise the pip installed in the Docker image is used. ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/12811) in GitLab 12.7) |
| `DS_PIP_DEPENDENCY_PATH` | `gemnasium-python` | | Path to load Python pip dependencies from. ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/12412) in GitLab 12.2) |
| `DS_PYTHON_VERSION` | `retire.js` | | Version of Python. If set to 2, dependencies are installed using Python 2.7 instead of Python 3.6. ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/12296) in GitLab 12.1)|
| `DS_JAVA_VERSION` | `gemnasium-maven` | `11` | Version of Java. Available versions: `8`, `11`, `13`, `14`. Maven and Gradle will use the Java version specified by this value. |
| `MAVEN_CLI_OPTS` | `gemnasium-maven` | `"-DskipTests --batch-mode"` | List of command line arguments that will be passed to `maven` by the analyzer. See an example for [using private repositories](../index.md#using-private-maven-repos). |
| `GRADLE_CLI_OPTS` | `gemnasium-maven` | | List of command line arguments that will be passed to `gradle` by the analyzer. |
| `SBT_CLI_OPTS` | `gemnasium-maven` | | List of command-line arguments that the analyzer will pass to `sbt`. |
......
......@@ -13,7 +13,7 @@ This is a [Closed Beta](https://about.gitlab.com/handbook/product/#closed-beta)
> - [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/709) in GitLab 12.1.
> - It's deployed behind a feature flag, disabled by default.
When [SSO for Groups]](index.md) is being enforced, groups can enable an additional level of protection by enforcing the creation of dedicated user accounts to access the group.
When [SSO for Groups](index.md) is being enforced, groups can enable an additional level of protection by enforcing the creation of dedicated user accounts to access the group.
With group-managed accounts enabled, users are required to create a new, dedicated user linked to the group.
The notification email address associated with the user is locked to the email address received from the configured identity provider.
......
......@@ -13,6 +13,11 @@ GitLab offers integrated cluster creation for the following Kubernetes providers
GitLab can also integrate with any standard Kubernetes provider, either on-premise or hosted.
NOTE: **Scalable app deployment with GitLab and Google Cloud Platform**
[Watch the webcast](https://about.gitlab.com/webcast/scalable-app-deploy/) and
learn how to spin up a Kubernetes cluster managed by Google Cloud Platform (GCP)
in a few clicks.
TIP: **Tip:**
Every new Google Cloud Platform (GCP) account receives [$300 in credit upon sign up](https://console.cloud.google.com/freetrial),
and in partnership with Google, GitLab is able to offer an additional $200 for new GCP accounts to get started with GitLab's
......
This diff is collapsed.
......@@ -1166,16 +1166,16 @@ For [manually configured Prometheus instances](#manual-configuration-of-promethe
> [Introduced](<https://gitlab.com/gitlab-org/gitlab/-/issues/40997>) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.9.
[Cluster Health Metrics](../clusters/index.md#monitoring-your-kubernetes-cluster-ultimate) can also be embedded in [GitLab-flavored Markdown](../../markdown.md).
[Cluster Health Metrics](../clusters/index.md#visualizing-cluster-health-ultimate) can also be embedded in [GitLab-flavored Markdown](../../markdown.md).
To embed a metric chart, include a link to that chart in the form `https://<root_url>/<project>/-/cluster/<cluster_id>?<query_params>` anywhere that GitLab-flavored Markdown is supported. To generate and copy a link to the chart, follow the instructions in the [Cluster Health Metric documentation](../clusters/index.md#monitoring-your-kubernetes-cluster-ultimate).
To embed a metric chart, include a link to that chart in the form `https://<root_url>/<project>/-/cluster/<cluster_id>?<query_params>` anywhere that GitLab-flavored Markdown is supported. To generate and copy a link to the chart, follow the instructions in the [Cluster Health Metric documentation](../clusters/index.md#visualizing-cluster-health-ultimate).
The following requirements must be met for the metric to unfurl:
- The `<cluster_id>` must correspond to a real cluster.
- Prometheus must be monitoring the cluster.
- The user must be allowed access to the project cluster metrics.
- The dashboards must be reporting data on the [Cluster Health Page](../clusters/index.md#monitoring-your-kubernetes-cluster-ultimate)
- The dashboards must be reporting data on the [Cluster Health Page](../clusters/index.md#visualizing-cluster-health-ultimate)
If the above requirements are met, then the metric will unfurl as seen below.
......
......@@ -83,7 +83,6 @@ Each alert contains the following metrics:
- **Severity** - The current importance of a alert and how much attention it should receive.
- **Start time** - How long ago the alert fired. This field uses the standard GitLab pattern of `X time ago`, but is supported by a granular date/time tooltip depending on the user's locale.
- **End time** - How long ago the alert fired was resolved. This field uses the standard GitLab pattern of `X time ago`, but is supported by a granular date/time tooltip depending on the user's locale.
- **Alert description** - The description of the alert, which attempts to capture the most meaningful data.
- **Event count** - The number of times that an alert has fired.
- **Status** - The [current status](#alert-management-statuses) of the alert.
......
......@@ -31,6 +31,7 @@ module API
expose :wiki_size
expose :lfs_objects_size
expose :build_artifacts_size, as: :job_artifacts_size
expose :snippets_size
end
end
end
......
......@@ -10,7 +10,6 @@ module Gitlab
Acme::Client::Error::Timeout
Acme::Client::Error::UnsupportedOperation
ActiveRecord::ConnectionTimeoutError
ActiveRecord::QueryCanceled
Gitlab::RequestContext::RequestDeadlineExceeded
GRPC::DeadlineExceeded
JIRA::HTTPError
......
......@@ -13264,6 +13264,9 @@ msgstr ""
msgid "License History"
msgstr ""
msgid "License ID:"
msgstr ""
msgid "License URL"
msgstr ""
......@@ -14096,6 +14099,9 @@ msgstr ""
msgid "MergeRequests|Squash task canceled: another squash is already in progress."
msgstr ""
msgid "MergeRequests|This project does not allow squashing commits when merge requests are accepted."
msgstr ""
msgid "MergeRequests|Thread stays resolved"
msgstr ""
......
......@@ -184,6 +184,7 @@ module Trigger
edition = Trigger.ee? ? 'EE' : 'CE'
{
"ee" => Trigger.ee? ? "true" : "false",
"GITLAB_VERSION" => ENV['CI_COMMIT_SHA'],
"GITLAB_TAG" => ENV['CI_COMMIT_TAG'],
"GITLAB_ASSETS_TAG" => ENV['CI_COMMIT_TAG'] ? ENV['CI_COMMIT_REF_NAME'] : ENV['CI_COMMIT_SHA'],
......
......@@ -442,7 +442,7 @@ RSpec.describe Projects::MergeRequestsController do
merge_request.update(squash: false)
merge_with_sha(squash: '1')
expect(merge_request.reload.squash).to be_truthy
expect(merge_request.reload.squash_on_merge?).to be_truthy
end
end
......@@ -451,7 +451,7 @@ RSpec.describe Projects::MergeRequestsController do
merge_request.update(squash: true)
merge_with_sha(squash: '0')
expect(merge_request.reload.squash).to be_falsey
expect(merge_request.reload.squash_on_merge?).to be_falsey
end
end
......
......@@ -184,11 +184,12 @@ RSpec.describe API::Groups do
it "includes statistics if requested" do
attributes = {
storage_size: 1158,
storage_size: 2392,
repository_size: 123,
wiki_size: 456,
lfs_objects_size: 234,
build_artifacts_size: 345
build_artifacts_size: 345,
snippets_size: 1234
}.stringify_keys
exposed_attributes = attributes.dup
exposed_attributes['job_artifacts_size'] = exposed_attributes.delete('build_artifacts_size')
......
......@@ -1930,7 +1930,7 @@ RSpec.describe API::MergeRequests do
it "updates the MR's squash attribute" do
expect do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { squash: true }
end.to change { merge_request.reload.squash }
end.to change { merge_request.reload.squash_on_merge? }
expect(response).to have_gitlab_http_status(:ok)
end
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe MergeRequestPollCachedWidgetEntity do
include ProjectForksHelper
using RSpec::Parameterized::TableSyntax
let(:project) { create :project, :repository }
let(:resource) { create(:merge_request, source_project: project, target_project: project) }
......@@ -181,6 +182,27 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do
end
end
describe 'squash defaults for projects' do
where(:squash_option, :value, :default, :readonly) do
'always' | true | true | true
'never' | false | false | true
'default_on' | false | true | false
'default_off' | false | false | false
end
with_them do
before do
project.project_setting.update!(squash_option: squash_option)
end
it 'the key reflects the correct value' do
expect(subject[:squash_on_merge]).to eq(value)
expect(subject[:squash_enabled_by_default]).to eq(default)
expect(subject[:squash_readonly]).to eq(readonly)
end
end
end
describe 'attributes for squash commit message' do
context 'when merge request is mergeable' do
before do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe MergeRequestPollWidgetEntity do
include ProjectForksHelper
using RSpec::Parameterized::TableSyntax
let(:project) { create :project, :repository }
let(:resource) { create(:merge_request, source_project: project, target_project: project) }
......@@ -171,6 +172,27 @@ RSpec.describe MergeRequestPollWidgetEntity do
end
end
describe 'squash defaults for projects' do
where(:squash_option, :value, :default, :readonly) do
'always' | true | true | true
'never' | false | false | true
'default_on' | false | true | false
'default_off' | false | false | false
end
with_them do
before do
project.project_setting.update!(squash_option: squash_option)
end
it 'the key reflects the correct value' do
expect(subject[:squash_on_merge]).to eq(value)
expect(subject[:squash_enabled_by_default]).to eq(default)
expect(subject[:squash_readonly]).to eq(readonly)
end
end
end
context 'when head pipeline is finished' do
before do
create(:ci_pipeline, :success, project: project,
......
......@@ -51,7 +51,7 @@ RSpec.describe AutoMerge::BaseService do
expect(merge_request.merge_params['commit_message']).to eq("Merge branch 'patch-12' into 'master'")
expect(merge_request.merge_params['sha']).to eq('200fcc9c260f7219eaf0daba87d818f0922c5b18')
expect(merge_request.merge_params['should_remove_source_branch']).to eq(false)
expect(merge_request.squash).to eq(false)
expect(merge_request.squash_on_merge?).to eq(false)
expect(merge_request.merge_params['squash_commit_message']).to eq('Update README.md')
end
end
......
......@@ -360,6 +360,25 @@ RSpec.describe MergeRequests::MergeService do
expect(Gitlab::AppLogger).to have_received(:error).with(a_string_matching(error_message))
end
context 'when squashing is required' do
before do
merge_request.update!(source_branch: 'master', target_branch: 'feature')
merge_request.target_project.project_setting.squash_always!
end
it 'raises an error if squashing is not done' do
error_message = 'requires squashing commits'
service.execute(merge_request)
expect(merge_request).to be_open
expect(merge_request.merge_commit_sha).to be_nil
expect(merge_request.merge_error).to include(error_message)
expect(Gitlab::AppLogger).to have_received(:error).with(a_string_matching(error_message))
end
end
context 'when squashing' do
before do
merge_request.update!(source_branch: 'master', target_branch: 'feature')
......
......@@ -131,6 +131,42 @@ RSpec.describe MergeRequests::SquashService do
include_examples 'the squash succeeds'
end
context 'when squashing is disabled by default on the project' do
# Squashing is disabled by default, but it should still allow you
# to squash-and-merge if selected through the UI
let(:merge_request) { merge_request_with_only_new_files }
before do
merge_request.project.project_setting.squash_default_off!
end
include_examples 'the squash succeeds'
end
context 'when squashing is forbidden on the project' do
let(:merge_request) { merge_request_with_only_new_files }
before do
merge_request.project.project_setting.squash_never!
end
it 'raises a squash error' do
expect(service.execute).to match(
status: :error,
message: a_string_including('does not allow squashing commits when merge requests are accepted'))
end
end
context 'when squashing is enabled by default on the project' do
let(:merge_request) { merge_request_with_only_new_files }
before do
merge_request.project.project_setting.squash_always!
end
include_examples 'the squash succeeds'
end
context 'when squashing with files too large to display' do
let(:merge_request) { merge_request_with_large_files }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment