Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 03:09:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 03:09:51 +0300
commit71da67f3262eeffe59cc228986e0a2bb97b6dba5 (patch)
tree426845fe569787b0ab1b2bae573fb1ae8ccb6fe1
parentf2dfd9ee819afb07bf11bd36a5f9d23009be0d39 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--GITLAB_WORKHORSE_VERSION2
-rw-r--r--app/models/alerting/project_alerting_setting.rb28
-rw-r--r--app/models/project.rb2
-rw-r--r--doc/ci/ci_cd_for_external_repos/index.md4
-rw-r--r--doc/user/img/new_personal_snippet_from_project_v12_10.pngbin0 -> 77106 bytes
-rw-r--r--doc/user/img/new_personal_snippet_v12_10.pngbin0 -> 39878 bytes
-rw-r--r--doc/user/img/new_project_snippet_from_project_v12_10.pngbin0 -> 73848 bytes
-rw-r--r--doc/user/project/repository/repository_mirroring.md3
-rw-r--r--doc/user/snippets.md27
-rw-r--r--spec/factories/project_alerting_settings.rb8
-rw-r--r--spec/models/alerting/project_alerting_setting_spec.rb40
-rw-r--r--spec/models/project_spec.rb1
12 files changed, 107 insertions, 8 deletions
diff --git a/GITLAB_WORKHORSE_VERSION b/GITLAB_WORKHORSE_VERSION
index c4ca5ee3475..ab7fcc3c4d6 100644
--- a/GITLAB_WORKHORSE_VERSION
+++ b/GITLAB_WORKHORSE_VERSION
@@ -1 +1 @@
-8.26.0
+8.27.0
diff --git a/app/models/alerting/project_alerting_setting.rb b/app/models/alerting/project_alerting_setting.rb
new file mode 100644
index 00000000000..8f8c38f11e4
--- /dev/null
+++ b/app/models/alerting/project_alerting_setting.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+require 'securerandom'
+
+module Alerting
+ class ProjectAlertingSetting < ApplicationRecord
+ belongs_to :project
+
+ validates :token, presence: true
+
+ attr_encrypted :token,
+ mode: :per_attribute_iv,
+ key: Settings.attr_encrypted_db_key_base_truncated,
+ algorithm: 'aes-256-gcm'
+
+ before_validation :ensure_token
+
+ private
+
+ def ensure_token
+ self.token ||= generate_token
+ end
+
+ def generate_token
+ SecureRandom.hex
+ end
+ end
+end
diff --git a/app/models/project.rb b/app/models/project.rb
index 7e006e734c5..e163b361bb8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -199,6 +199,7 @@ class Project < ApplicationRecord
has_one :metrics_setting, inverse_of: :project, class_name: 'ProjectMetricsSetting'
has_one :grafana_integration, inverse_of: :project
has_one :project_setting, ->(project) { where_or_create_by(project: project) }, inverse_of: :project
+ has_one :alerting_setting, inverse_of: :project, class_name: 'Alerting::ProjectAlertingSetting'
# Merge Requests for target project should be removed with it
has_many :merge_requests, foreign_key: 'target_project_id', inverse_of: :target_project
@@ -332,6 +333,7 @@ class Project < ApplicationRecord
accepts_nested_attributes_for :metrics_setting, update_only: true, allow_destroy: true
accepts_nested_attributes_for :grafana_integration, update_only: true, allow_destroy: true
accepts_nested_attributes_for :prometheus_service, update_only: true
+ accepts_nested_attributes_for :alerting_setting, update_only: true
delegate :feature_available?, :builds_enabled?, :wiki_enabled?,
:merge_requests_enabled?, :forking_enabled?, :issues_enabled?,
diff --git a/doc/ci/ci_cd_for_external_repos/index.md b/doc/ci/ci_cd_for_external_repos/index.md
index 25598241c9b..704894f51b3 100644
--- a/doc/ci/ci_cd_for_external_repos/index.md
+++ b/doc/ci/ci_cd_for_external_repos/index.md
@@ -6,10 +6,6 @@ type: index, howto
>[Introduced][ee-4642] in [GitLab Premium][eep] 10.6.
-NOTE: **Note:**
-This feature [is available for free](https://about.gitlab.com/blog/2019/09/09/ci-cd-github-extended-again/) to
-GitLab.com users until March 22nd, 2020.
-
GitLab CI/CD can be used with:
- [GitHub](github_integration.md).
diff --git a/doc/user/img/new_personal_snippet_from_project_v12_10.png b/doc/user/img/new_personal_snippet_from_project_v12_10.png
new file mode 100644
index 00000000000..af8cce01208
--- /dev/null
+++ b/doc/user/img/new_personal_snippet_from_project_v12_10.png
Binary files differ
diff --git a/doc/user/img/new_personal_snippet_v12_10.png b/doc/user/img/new_personal_snippet_v12_10.png
new file mode 100644
index 00000000000..a995e4d4b40
--- /dev/null
+++ b/doc/user/img/new_personal_snippet_v12_10.png
Binary files differ
diff --git a/doc/user/img/new_project_snippet_from_project_v12_10.png b/doc/user/img/new_project_snippet_from_project_v12_10.png
new file mode 100644
index 00000000000..7fa17beaae6
--- /dev/null
+++ b/doc/user/img/new_project_snippet_from_project_v12_10.png
Binary files differ
diff --git a/doc/user/project/repository/repository_mirroring.md b/doc/user/project/repository/repository_mirroring.md
index 33fa09255e1..7c28e956e12 100644
--- a/doc/user/project/repository/repository_mirroring.md
+++ b/doc/user/project/repository/repository_mirroring.md
@@ -110,9 +110,6 @@ The repository will push soon. To force a push, click the appropriate button.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51) in GitLab Enterprise Edition 8.2.
> - [Added Git LFS support](https://gitlab.com/gitlab-org/gitlab/issues/10871) in [GitLab Starter](https://about.gitlab.com/pricing/) 11.11.
-NOTE: **Note:** This feature [is available for free](https://gitlab.com/gitlab-org/gitlab/issues/10361) to
-GitLab.com users until March 22nd, 2020.
-
You can set up a repository to automatically have its branches, tags, and commits updated from an
upstream repository.
diff --git a/doc/user/snippets.md b/doc/user/snippets.md
index 77997c53210..0372bb42038 100644
--- a/doc/user/snippets.md
+++ b/doc/user/snippets.md
@@ -22,6 +22,33 @@ and private. See [Public access](../public_access/public_access.md) for more inf
Project snippets are always related to a specific project.
See [Project features](project/index.md#project-features) for more information.
+## Create a snippet
+
+To create a personal snippet, click the plus icon (**{plus-square-o}**)
+on the top navigation and select **New snippet** from the dropdown menu:
+
+![New personal snippet from non-project pages](img/new_personal_snippet_v12_10.png)
+
+If you're on a project's page but you want to create a new personal snippet,
+click the plus icon (**{plus-square-o}**) and select **New snippet** from the
+lower part of the dropdown (**GitLab** on GitLab.com; **Your Instance** on
+self-managed instances):
+
+![New personal snippet from project pages](img/new_personal_snippet_from_project_v12_10.png)
+
+To create a project snippet, navigate to your project's page and click the
+plus icon (**{plus-square-o}**), then select **New snippet** from the upper
+part of the dropdown (**This project**).
+
+![New personal snippet from project pages](img/new_project_snippet_from_project_v12_10.png)
+
+From there, add the **Title**, **Description**, and a **File** name with the
+appropriate extension (for example, `example.rb`, `index.html`).
+
+CAUTION: **Warning:**
+Make sure to add the file name to get code highlighting and to avoid this
+[copy-pasting bug](https://gitlab.com/gitlab-org/gitlab/-/issues/22870).
+
## Discover snippets
There are two main ways of how you can discover snippets in GitLab.
diff --git a/spec/factories/project_alerting_settings.rb b/spec/factories/project_alerting_settings.rb
new file mode 100644
index 00000000000..2c8ca7c70a8
--- /dev/null
+++ b/spec/factories/project_alerting_settings.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :project_alerting_setting, class: 'Alerting::ProjectAlertingSetting' do
+ project
+ token { 'access_token_123' }
+ end
+end
diff --git a/spec/models/alerting/project_alerting_setting_spec.rb b/spec/models/alerting/project_alerting_setting_spec.rb
new file mode 100644
index 00000000000..40fbe3a6e78
--- /dev/null
+++ b/spec/models/alerting/project_alerting_setting_spec.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Alerting::ProjectAlertingSetting do
+ let_it_be(:project) { create(:project) }
+
+ subject { create(:project_alerting_setting, project: project) }
+
+ describe 'Associations' do
+ it { is_expected.to belong_to(:project) }
+ end
+
+ describe '#token' do
+ context 'when set' do
+ let(:token) { SecureRandom.hex }
+
+ subject do
+ create(:project_alerting_setting, project: project, token: token)
+ end
+
+ it 'reads the token' do
+ expect(subject.token).to eq(token)
+ expect(subject.encrypted_token).not_to be_nil
+ expect(subject.encrypted_token_iv).not_to be_nil
+ end
+ end
+
+ context 'when not set' do
+ before do
+ subject.token = nil
+ end
+
+ it 'generates a token before validation' do
+ expect(subject).to be_valid
+ expect(subject.token).to match(/\A\h{32}\z/)
+ end
+ end
+ end
+end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 15b409b2dcf..44be4985439 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -70,6 +70,7 @@ describe Project do
it { is_expected.to have_one(:auto_devops).class_name('ProjectAutoDevops') }
it { is_expected.to have_one(:error_tracking_setting).class_name('ErrorTracking::ProjectErrorTrackingSetting') }
it { is_expected.to have_one(:project_setting) }
+ it { is_expected.to have_one(:alerting_setting).class_name('Alerting::ProjectAlertingSetting') }
it { is_expected.to have_many(:commit_statuses) }
it { is_expected.to have_many(:ci_pipelines) }
it { is_expected.to have_many(:ci_refs) }