Skip to content
Snippets Groups Projects
Verified Commit f64143ad authored by Jesse Hall's avatar Jesse Hall
Browse files

Updates to docs and default commit message.

parent a0ac02a3
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !22439. Comments created here will be created in the context of that merge request.
......@@ -527,14 +527,15 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
.then(() => Promise.all(resolveAllDiscussions()))
.then(() => commit(types.CLEAR_SUGGESTION_BATCH))
.catch(err => {
commit(types.SET_APPLYING_BATCH_STATE, false);
const defaultMessage = __(
'Something went wrong while applying the batch of suggestions. Please try again.',
);
const flashMessage = err.response.data ? `${err.response.data.message}.` : defaultMessage;
Flash(__(flashMessage), 'alert', flashContainer);
})
.finally(() => commit(types.SET_APPLYING_BATCH_STATE, false));
});
};
export const addSuggestionInfoToBatch = ({ commit }, { suggestionId, noteId, discussionId }) =>
......
......@@ -2,12 +2,12 @@
module Suggestions
class ApplyService < ::BaseService
DEFAULT_SUGGESTION_COMMIT_MESSAGE = 'Apply %{suggestions_count} suggestion(s) to file(s): %{file_paths}'
DEFAULT_SUGGESTION_COMMIT_MESSAGE = "Apply %{suggestions_count} suggestion(s) to:\n%{file_paths}"
PLACEHOLDERS = {
'project_path' => ->(suggestions, user) { suggestions[0].project.path },
'project_name' => ->(suggestions, user) { suggestions[0].project.name },
'file_paths' => ->(suggestions, user) { suggestions.map(&:file_path).uniq.sort.join(" ") },
'file_paths' => ->(suggestions, user) { suggestions.map(&:file_path).uniq.sort.join("\n") },
'branch_name' => ->(suggestions, user) { suggestions[0].branch },
'suggestions_count' => ->(suggestions, user) { suggestions.size },
'username' => ->(suggestions, user) { user.username },
......
......@@ -8,8 +8,10 @@
help_page_path('user/discussions/index.md',
anchor: 'configure-the-commit-message-for-applied-suggestions'),
target: '_blank'
%br
= s_('ProjectSettings|Individual file paths will appear on separate lines.')
.mb-2
= form.text_field :suggestion_commit_message, class: 'form-control mb-2', placeholder: Suggestions::ApplyService::DEFAULT_SUGGESTION_COMMIT_MESSAGE
= form.text_area :suggestion_commit_message, rows: 2, class: 'form-control mb-2', placeholder: Suggestions::ApplyService::DEFAULT_SUGGESTION_COMMIT_MESSAGE
%p.form-text.text-muted
= s_('ProjectSettings|The variables GitLab supports:')
- Suggestions::ApplyService::PLACEHOLDERS.keys.each do |placeholder|
......
doc/user/discussions/img/suggestions_custom_commit_messages_v12_7.png

21.2 KiB

doc/user/discussions/img/suggestions_custom_commit_messages_v12_9.jpg

36 KiB

......@@ -451,20 +451,33 @@ instead of the usual three.
### Configure the commit message for applied Suggestions
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/13086) in GitLab 12.7.
> - Support for batch Suggestions was [introduced](https://gitlab.com/gitlab-org/gitlab/issues/25486) in GitLab 12.9.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/13086) in GitLab 12.7.
From [GitLab 12.9](https://gitlab.com/gitlab-org/gitlab/issues/25486) onwards, you can apply multiple suggestions at once
(batch Suggestions) and the default commit message for applied suggestions is given by `Apply %{suggestions_count} suggestion(s) to file(s): %{file_paths}`.
GitLab uses a default commit message
when applying Suggestions:
For example, consider that a user applied 3 suggestions at once to 2 different files, the default
commit message would be: **Apply 3 suggestions to files: path/to/file1.rb, path/to/file2.rb**.
```
Apply %{suggestions_count} suggestion(s) to:
%{file_paths}
```
For example, consider that a user applied 3 suggestions at to 2 different files, the default commit message would be:
<br>
<br>
**Apply 3 suggestion(s) to:**
<br>
**path/to/file1.rb**
<br>
**path/to/file2.rb**
<br>
Note that `%{file_paths}` has special handling, as each file path will appear on separate lines.
These commit messages can be customized to follow any guidelines you might have. To do so, expand the **Merge requests**
tab within your project's **General** settings and change the
**Merge suggestions** text:
![Custom commit message for applied Suggestions](img/suggestions_custom_commit_messages_v12_7.png)
![Custom commit message for applied Suggestions](img/suggestions_custom_commit_messages_v12_9.jpg)
You can also use following variables besides static text:
......@@ -472,7 +485,7 @@ You can also use following variables besides static text:
|---|---|---|
| `%{project_path}` | The project path. | `my-group/my-project` |
| `%{project_name}` | The human-readable name of the project. | **My Project** |
| `%{file_paths}` | The path(s) of the file(s) the Suggestion(s) is (are) applied to. | `docs/index.md, docs/about.md` |
| `%{file_paths}` | The path(s) of the file(s) the Suggestion(s) is (are) applied to. <br> Each file path will appear on a separate line.| `docs/index.md` <br> `docs/about.md` |
| `%{branch_name}` | The name of the branch the Suggestion(s) is (are) applied on. | `my-feature-branch` |
| `%{username}` | The username of the user applying the Suggestion(s). | `user_1` |
| `%{user_full_name}` | The full name of the user applying the Suggestion(s). | **User 1** |
......@@ -485,6 +498,15 @@ NOTE: **Note:**
Custom commit messages for each applied Suggestion (or batch Suggestions) will be
introduced by [#25381](https://gitlab.com/gitlab-org/gitlab/issues/25381).
### Applying Batch Suggestions
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/25486) in GitLab 12.9.
You can apply multiple suggestions at once to reduce the number of commits added
to your branch to address your reviewers' requests.
**To do so, --steps on how to do this go here--.**
## Start a thread by replying to a standard comment
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/issues/30299) in GitLab 11.9
......
......@@ -15269,6 +15269,9 @@ msgstr ""
msgid "ProjectSettings|Git Large File Storage"
msgstr ""
 
msgid "ProjectSettings|Individual file paths will appear on separate lines."
msgstr ""
msgid "ProjectSettings|Internal"
msgstr ""
 
......
......@@ -905,14 +905,13 @@ describe('Actions Notes Store', () => {
.catch(done.fail);
};
it('when service succeeds, commits, resolves discussions, clears batch, and resets applying batch state', done => {
it('when service succeeds, commits, resolves discussions and clears batch', done => {
testSubmitSuggestionBatch(done, () => {
expect(commit.calls.allArgs()).toEqual([
[mutationTypes.SET_APPLYING_BATCH_STATE, true],
[mutationTypes.APPLY_SUGGESTION, batchSuggestionsInfo[0]],
[mutationTypes.APPLY_SUGGESTION, batchSuggestionsInfo[1]],
[mutationTypes.CLEAR_SUGGESTION_BATCH],
[mutationTypes.SET_APPLYING_BATCH_STATE, false],
]);
expect(dispatch.calls.allArgs()).toEqual([
......@@ -924,7 +923,7 @@ describe('Actions Notes Store', () => {
});
});
it('when service fails, flashes error message, resets applying batch state', done => {
it('when service fails, flashes error message and resets applying batch state', done => {
const response = { response: { data: { message: TEST_ERROR_MESSAGE } } };
Api.applySuggestionBatch.and.returnValue(Promise.reject(response));
......@@ -940,7 +939,7 @@ describe('Actions Notes Store', () => {
});
});
it('when resolve discussions fails, fails gracefully, clears batch, resets applying batch state', done => {
it('when resolve discussions fails, fails gracefully and clears batch', done => {
dispatch.and.returnValue(Promise.reject());
testSubmitSuggestionBatch(done, () => {
......@@ -949,7 +948,6 @@ describe('Actions Notes Store', () => {
[mutationTypes.APPLY_SUGGESTION, batchSuggestionsInfo[0]],
[mutationTypes.APPLY_SUGGESTION, batchSuggestionsInfo[1]],
[mutationTypes.CLEAR_SUGGESTION_BATCH],
[mutationTypes.SET_APPLYING_BATCH_STATE, false],
]);
expect(flashSpy).not.toHaveBeenCalled();
......
......@@ -21,7 +21,7 @@ def apply(suggestions)
end
def file_paths(expected_content_by_path)
expected_content_by_path.keys.sort.join(" ")
expected_content_by_path.keys.sort.join("\n")
end
shared_examples 'successfully creates commit and updates suggestions' do
......@@ -69,7 +69,7 @@ def file_paths(expected_content_by_path)
context 'is not specified' do
let(:expected_value) do
"Apply #{suggestions.size} suggestion(s) to file(s): #{file_paths(expected_content_by_path)}"
"Apply #{suggestions.size} suggestion(s) to:\n#{file_paths(expected_content_by_path)}"
end
context 'is nil' do
......
......@@ -43,7 +43,7 @@
it 'displays a placeholder if none is set' do
render
expect(rendered).to have_field('project[suggestion_commit_message]', placeholder: 'Apply %{suggestions_count} suggestion(s) to file(s): %{file_paths}')
expect(rendered).to have_field('project[suggestion_commit_message]', placeholder: "Apply %{suggestions_count} suggestion(s) to:\n%{file_paths}")
end
it 'displays the user entered value' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment