diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-27 06:11:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-27 06:11:36 +0300 |
commit | 1f7ce4357df88bed6394d3ba91a7ecd90c244486 (patch) | |
tree | 9227d482e7f96aff91d1c09056830c53dfff2900 | |
parent | f938050604aff3e141193dcd203d14c5fe2aa9fb (diff) |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | app/models/note.rb | 2 | ||||
-rw-r--r-- | doc/.vale/gitlab/Acronyms.yml | 2 | ||||
-rw-r--r-- | doc/api/project_level_variables.md | 83 | ||||
-rw-r--r-- | doc/api/project_statistics.md | 8 | ||||
-rw-r--r-- | doc/ci/yaml/index.md | 4 | ||||
-rw-r--r-- | doc/user/permissions.md | 2 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 28 |
7 files changed, 83 insertions, 46 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index a8f5c305d9b..2defa1d1ca5 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -149,7 +149,7 @@ class Note < ApplicationRecord scope :like_note_or_capitalized_note, ->(text) { where('(note LIKE ? OR note LIKE ?)', text, text.capitalize) } before_validation :nullify_blank_type, :nullify_blank_line_code - after_save :keep_around_commit, if: :for_project_noteable?, unless: :importing? + after_save :keep_around_commit, if: :for_project_noteable?, unless: -> { importing? || skip_keep_around_commits } after_save :expire_etag_cache, unless: :importing? after_save :touch_noteable, unless: :importing? after_destroy :expire_etag_cache diff --git a/doc/.vale/gitlab/Acronyms.yml b/doc/.vale/gitlab/Acronyms.yml index 0edba1852e7..ecb1dd33fa8 100644 --- a/doc/.vale/gitlab/Acronyms.yml +++ b/doc/.vale/gitlab/Acronyms.yml @@ -62,6 +62,7 @@ exceptions: - GDK - GDPR - GET + - GID - GIF - GKE - GNU @@ -173,6 +174,7 @@ exceptions: - TOML - TTL - UDP + - UID - UNIX - URI - URL diff --git a/doc/api/project_level_variables.md b/doc/api/project_level_variables.md index 2dcef40aacb..a2c2da9065f 100644 --- a/doc/api/project_level_variables.md +++ b/doc/api/project_level_variables.md @@ -15,8 +15,8 @@ Get list of a project's variables. GET /projects/:id/variables ``` -| Attribute | Type | required | Description | -|-----------|---------|----------|---------------------| +| Attribute | Type | required | Description | +| --------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | ```shell @@ -26,14 +26,20 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a ```json [ { - "key": "TEST_VARIABLE_1", "variable_type": "env_var", - "value": "TEST_1" + "key": "TEST_VARIABLE_1", + "value": "TEST_1", + "protected": false, + "masked": true, + "environment_scope": "*" }, { - "key": "TEST_VARIABLE_2", "variable_type": "env_var", - "value": "TEST_2" + "key": "TEST_VARIABLE_2", + "value": "TEST_2", + "protected": false, + "masked": false, + "environment_scope": "*" } ] ``` @@ -46,11 +52,11 @@ Get the details of a project's specific variable. GET /projects/:id/variables/:key ``` -| Attribute | Type | required | Description | -|-----------|---------|----------|-----------------------| -| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | -| `key` | string | yes | The `key` of a variable | -| `filter` | hash | no | Available filters: `[environment_scope]`. See the [`filter` parameter details](#the-filter-parameter). | +| Attribute | Type | required | Description | +| --------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | +| `key` | string | yes | The `key` of a variable | +| `filter` | hash | no | Available filters: `[environment_scope]`. See the [`filter` parameter details](#the-filter-parameter). | ```shell curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables/TEST_VARIABLE_1" @@ -62,7 +68,8 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a "variable_type": "env_var", "value": "TEST_1", "protected": false, - "masked": true + "masked": true, + "environment_scope": "*" } ``` @@ -74,15 +81,15 @@ Create a new variable. POST /projects/:id/variables ``` -| Attribute | Type | required | Description | -|---------------------|---------|----------|-----------------------| -| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | -| `key` | string | yes | The `key` of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9`, and `_` are allowed | -| `value` | string | yes | The `value` of a variable | -| `variable_type` | string | no | The type of a variable. Available types are: `env_var` (default) and `file` | -| `protected` | boolean | no | Whether the variable is protected. Default: `false` | -| `masked` | boolean | no | Whether the variable is masked. Default: `false` | -| `environment_scope` | string | no | The `environment_scope` of the variable. Default: `*` | +| Attribute | Type | required | Description | +| ------------------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | +| `key` | string | yes | The `key` of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9`, and `_` are allowed | +| `value` | string | yes | The `value` of a variable | +| `variable_type` | string | no | The type of a variable. Available types are: `env_var` (default) and `file` | +| `protected` | boolean | no | Whether the variable is protected. Default: `false` | +| `masked` | boolean | no | Whether the variable is masked. Default: `false` | +| `environment_scope` | string | no | The `environment_scope` of the variable. Default: `*` | ```shell curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ @@ -91,10 +98,10 @@ curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ ```json { + "variable_type": "env_var", "key": "NEW_VARIABLE", "value": "new value", "protected": false, - "variable_type": "env_var", "masked": false, "environment_scope": "*" } @@ -108,16 +115,16 @@ Update a project's variable. PUT /projects/:id/variables/:key ``` -| Attribute | Type | required | Description | -|---------------------|---------|----------|-------------------------| -| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | -| `key` | string | yes | The `key` of a variable | -| `value` | string | yes | The `value` of a variable | -| `variable_type` | string | no | The type of a variable. Available types are: `env_var` (default) and `file` | -| `protected` | boolean | no | Whether the variable is protected | -| `masked` | boolean | no | Whether the variable is masked | -| `environment_scope` | string | no | The `environment_scope` of the variable | -| `filter` | hash | no | Available filters: `[environment_scope]`. See the [`filter` parameter details](#the-filter-parameter). | +| Attribute | Type | required | Description | +| ------------------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | +| `key` | string | yes | The `key` of a variable | +| `value` | string | yes | The `value` of a variable | +| `variable_type` | string | no | The type of a variable. Available types are: `env_var` (default) and `file` | +| `protected` | boolean | no | Whether the variable is protected | +| `masked` | boolean | no | Whether the variable is masked | +| `environment_scope` | string | no | The `environment_scope` of the variable | +| `filter` | hash | no | Available filters: `[environment_scope]`. See the [`filter` parameter details](#the-filter-parameter). | ```shell curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \ @@ -126,9 +133,9 @@ curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \ ```json { + "variable_type": "env_var", "key": "NEW_VARIABLE", "value": "updated value", - "variable_type": "env_var", "protected": true, "masked": false, "environment_scope": "*" @@ -143,11 +150,11 @@ Remove a project's variable. DELETE /projects/:id/variables/:key ``` -| Attribute | Type | required | Description | -|-----------|---------|----------|-------------------------| -| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | -| `key` | string | yes | The `key` of a variable | -| `filter` | hash | no | Available filters: `[environment_scope]`. See the [`filter` parameter details](#the-filter-parameter). | +| Attribute | Type | required | Description | +| --------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user | +| `key` | string | yes | The `key` of a variable | +| `filter` | hash | no | Available filters: `[environment_scope]`. See the [`filter` parameter details](#the-filter-parameter). | ```shell curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables/VARIABLE_1" diff --git a/doc/api/project_statistics.md b/doc/api/project_statistics.md index a16bcc513f9..c69e41a423e 100644 --- a/doc/api/project_statistics.md +++ b/doc/api/project_statistics.md @@ -8,12 +8,12 @@ type: reference, api # Project statistics API **(FREE)** Every API call to [project](../user/project/index.md) statistics must be authenticated. +Retrieving these statistics requires write access to the repository. -## Get the statistics of the last 30 days +This API retrieves the number of times the project is either cloned or pulled +with the HTTP method. SSH fetches are not included. -Retrieving the statistics requires write access to the repository. -Currently only HTTP fetches statistics are returned. -Fetches statistics includes both clones and pulls count and are HTTP only, SSH fetches are not included. +## Get the statistics of the last 30 days ```plaintext GET /projects/:id/statistics diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index 4ad94a14125..b9b4e1faafb 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -747,9 +747,9 @@ Use `before_script` to define an array of commands that should run before each j ```yaml job: before_script: - - echo "Execute this command before any `script:` commands." + - echo "Execute this command before any 'script:' commands." script: - - echo "This command executes after the job's `before_script` commands." + - echo "This command executes after the job's 'before_script' commands." ``` **Additional details**: diff --git a/doc/user/permissions.md b/doc/user/permissions.md index 853d649ab9c..116982641c9 100644 --- a/doc/user/permissions.md +++ b/doc/user/permissions.md @@ -132,7 +132,7 @@ The following table lists project permissions available for each role: | [Projects](project/index.md):<br>View [wiki](project/wiki/index.md) pages | ✓ | ✓ | ✓ | ✓ | ✓ | | [Projects](project/index.md):<br>Create [snippets](snippets.md) | | ✓ | ✓ | ✓ | ✓ | | [Projects](project/index.md):<br>Manage labels | | ✓ | ✓ | ✓ | ✓ | -| [Projects](project/index.md):<br>View project statistics | | ✓ | ✓ | ✓ | ✓ | +| [Projects](project/index.md):<br>View [project traffic statistics](../api/project_statistics.md) | | ✓ | ✓ | ✓ | ✓ | | [Projects](project/index.md):<br>Create, edit, delete [milestones](project/milestones/index.md). | | | ✓ | ✓ | ✓ | | [Projects](project/index.md):<br>Create, edit, delete [releases](project/releases/index.md) | | | ✓ (*13*) | ✓ (*13*) | ✓ (*13*) | | [Projects](project/index.md):<br>Create, edit [wiki](project/wiki/index.md) pages | | | ✓ | ✓ | ✓ | diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 5e3773513f1..0dd77967f25 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -108,6 +108,34 @@ RSpec.describe Note do end describe 'callbacks' do + describe '#keep_around_commit' do + let!(:noteable) { create(:issue) } + + it "calls #keep_around_commit normally" do + note = build(:note, project: noteable.project, noteable: noteable) + + expect(note).to receive(:keep_around_commit) + + note.save! + end + + it "skips #keep_around_commit if 'skip_keep_around_commits' is true" do + note = build(:note, project: noteable.project, noteable: noteable, skip_keep_around_commits: true) + + expect(note).not_to receive(:keep_around_commit) + + note.save! + end + + it "skips #keep_around_commit if 'importing' is true" do + note = build(:note, project: noteable.project, noteable: noteable, importing: true) + + expect(note).not_to receive(:keep_around_commit) + + note.save! + end + end + describe '#notify_after_create' do it 'calls #after_note_created on the noteable' do noteable = create(:issue) |