Commit 570c89dc authored by Nick Thomas's avatar Nick Thomas

Merge branch 'docs-review-custom-commit-m-suggestions' into 'master'

Post-merge doc review: custom commit messages for applied Suggestions

See merge request gitlab-org/gitlab!23067
parents 01ec170d a09fc52c
...@@ -390,8 +390,8 @@ As a reviewer, you're able to suggest code changes with a simple ...@@ -390,8 +390,8 @@ As a reviewer, you're able to suggest code changes with a simple
Markdown syntax in Merge Request Diff threads. Then, the Markdown syntax in Merge Request Diff threads. Then, the
Merge Request author (or other users with appropriate Merge Request author (or other users with appropriate
[permission](../permissions.md)) is able to apply these [permission](../permissions.md)) is able to apply these
suggestions with a click, which will generate a commit in Suggestions with a click, which will generate a commit in
the Merge Request authored by the user that applied them. the merge request authored by the user that applied them.
1. Choose a line of code to be changed, add a new comment, then click 1. Choose a line of code to be changed, add a new comment, then click
on the **Insert suggestion** icon in the toolbar: on the **Insert suggestion** icon in the toolbar:
...@@ -407,32 +407,28 @@ the Merge Request authored by the user that applied them. ...@@ -407,32 +407,28 @@ the Merge Request authored by the user that applied them.
NOTE: **Note:** NOTE: **Note:**
If you're using GitLab Premium, GitLab.com Silver, and higher tiers, the thread will display [Review](#merge-request-reviews-premium) options. Click either **Start a review**, **Add comment now**, or **Add to review** to obtain the same result. If you're using GitLab Premium, GitLab.com Silver, and higher tiers, the thread will display [Review](#merge-request-reviews-premium) options. Click either **Start a review**, **Add comment now**, or **Add to review** to obtain the same result.
The suggestions in the comment can be applied by the merge request author The Suggestion in the comment can be applied by the merge request author
directly from the merge request: directly from the merge request:
![Apply suggestions](img/apply_suggestion_v12_7.png) ![Apply suggestions](img/apply_suggestion_v12_7.png)
Once the author applies a suggestion, it will be marked with the **Applied** label, Once the author applies a Suggestion, it will be marked with the **Applied** label,
the thread will be automatically resolved, and GitLab will create a new commit the thread will be automatically resolved, and GitLab will create a new commit
and push the suggested change directly into the codebase in the merge request's and push the suggested change directly into the codebase in the merge request's
branch. [Developer permission](../permissions.md) is required to do so. branch. [Developer permission](../permissions.md) is required to do so.
> **Note:** ### Multi-line Suggestions
Custom commit messages will be introduced by
[#54404](https://gitlab.com/gitlab-org/gitlab-foss/issues/54404).
### Multi-line suggestions
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/issues/53310) in GitLab 11.10. > [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/issues/53310) in GitLab 11.10.
Reviewers can also suggest changes to multiple lines with a single suggestion Reviewers can also suggest changes to multiple lines with a single Suggestion
within Merge Request diff threads by adjusting the range offsets. The within merge request diff threads by adjusting the range offsets. The
offsets are relative to the position of the diff thread, and specify the offsets are relative to the position of the diff thread, and specify the
range to be replaced by the suggestion when it is applied. range to be replaced by the suggestion when it is applied.
![Multi-line suggestion syntax](img/multi-line-suggestion-syntax.png) ![Multi-line suggestion syntax](img/multi-line-suggestion-syntax.png)
In the example above, the suggestion covers three lines above and four lines In the example above, the Suggestion covers three lines above and four lines
below the commented line. When applied, it would replace from 3 lines _above_ below the commented line. When applied, it would replace from 3 lines _above_
to 4 lines _below_ the commented line, with the suggested change. to 4 lines _below_ the commented line, with the suggested change.
...@@ -443,23 +439,36 @@ Suggestions covering multiple lines are limited to 100 lines _above_ and 100 ...@@ -443,23 +439,36 @@ Suggestions covering multiple lines are limited to 100 lines _above_ and 100
lines _below_ the commented diff line, allowing up to 200 changed lines per lines _below_ the commented diff line, allowing up to 200 changed lines per
suggestion. suggestion.
### Configure the commit message for applied suggestions ### Configure the commit message for applied Suggestions
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/13086) in GitLab 12.7.
GitLab will use `Apply suggestion to %{file_path}` by default as commit messages GitLab uses `Apply suggestion to %{file_path}` by default as commit messages
when applying change suggestions. This commit message can be customized to when applying Suggestions. This commit message can be customized to
follow any guidelines you might have. To do so, open the **Merge requests** tab follow any guidelines you might have. To do so, expand the **Merge requests**
within your project settings and change the **Merge suggestions** text. tab within your project's **General** settings and change the
**Merge suggestions** text:
![Suggestion Commit Message Configuration](img/suggestion-commit-message-configuration.png) ![Custom commit message for applied Suggestions](img/suggestions_custom_commit_messages_v12_7.png)
You can also use following variables besides static text: You can also use following variables besides static text:
- `%{project_path}`: The full URL safe project path. E.g: *my-group/my-project* | Variable | Description | Output example |
- `%{project_name}`: The human readable name of the project. E.g: *My Project* |---|---|---|
- `%{file_path}`: The full path of the file the suggestion is applied to. E.g: *docs/index.md* | `%{project_path}` | The project path. | `my-group/my-project` |
- `%{branch_name}`: The name of the branch the suggestion is applied on. E.g: *my-feature-branch* | `%{project_name}` | The human-readable name of the project. | **My Project** |
- `%{username}`: The username of the user applying the suggestion. E.g: *user_1* | `%{file_path}` | The path of the file the Suggestion is applied to. | `docs/index.md` |
- `%{user_full_name}`: The full name of the user applying the suggestion. E.g: *User 1* | `%{branch_name}` | The name of the branch the Suggestion is applied on. | `my-feature-branch` |
| `%{username}` | The username of the user applying the Suggestion. | `user_1` |
| `%{user_full_name}` | The full name of the user applying the Suggestion. | `**User 1** |
For example, to customize the commit message to output
**Addresses user_1's review**, set the custom text to
`Adresses %{username}'s review`.
NOTE: **Note:**
Custom commit messages for each applied Suggestion will be
introduced by [#25381](https://gitlab.com/gitlab-org/gitlab/issues/25381).
## Start a thread by replying to a standard comment ## Start a thread by replying to a standard comment
......
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