Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
650fd1a8
Commit
650fd1a8
authored
Jan 25, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
d1133061
7c7916ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
16 deletions
+22
-16
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+6
-5
app/services/suggestions/apply_service.rb
app/services/suggestions/apply_service.rb
+8
-7
changelogs/unreleased/osw-adjusts-suggestions-unable-to-be-applied.yml
...released/osw-adjusts-suggestions-unable-to-be-applied.yml
+5
-0
spec/services/suggestions/apply_service_spec.rb
spec/services/suggestions/apply_service_spec.rb
+3
-4
No files found.
app/assets/javascripts/notes/stores/actions.js
View file @
650fd1a8
...
...
@@ -415,12 +415,13 @@ export const submitSuggestion = (
commit
(
types
.
APPLY_SUGGESTION
,
{
discussionId
,
noteId
,
suggestionId
});
callback
();
})
.
catch
(()
=>
{
Flash
(
__
(
'
Something went wrong while applying the suggestion. Please try again.
'
),
'
alert
'
,
flashContainer
,
.
catch
(
err
=>
{
const
defaultMessage
=
__
(
'
Something went wrong while applying the suggestion. Please try again.
'
,
);
const
flashMessage
=
err
.
response
.
data
?
`
${
err
.
response
.
data
.
message
}
.`
:
defaultMessage
;
Flash
(
__
(
flashMessage
),
'
alert
'
,
flashContainer
);
callback
();
});
};
...
...
app/services/suggestions/apply_service.rb
View file @
650fd1a8
...
...
@@ -11,7 +11,7 @@ module Suggestions
return
error
(
'Suggestion is not appliable'
)
end
unless
latest_
diff_refs
?
(
suggestion
)
unless
latest_
source_head
?
(
suggestion
)
return
error
(
'The file has been changed'
)
end
...
...
@@ -29,12 +29,13 @@ module Suggestions
private
# Checks whether the latest diff refs for the branch matches with
# the position refs we're using to update the file content. Since
# the persisted refs are updated async (for MergeRequest),
# it's more consistent to fetch this data directly from the repository.
def
latest_diff_refs?
(
suggestion
)
suggestion
.
position
.
diff_refs
==
suggestion
.
noteable
.
repository_diff_refs
# Checks whether the latest source branch HEAD matches with
# the position HEAD we're using to update the file content. Since
# the persisted HEAD is updated async (for MergeRequest),
# it's more consistent to fetch this data directly from the
# repository.
def
latest_source_head?
(
suggestion
)
suggestion
.
position
.
head_sha
==
suggestion
.
noteable
.
source_branch_sha
end
def
file_update_params
(
suggestion
)
...
...
changelogs/unreleased/osw-adjusts-suggestions-unable-to-be-applied.yml
0 → 100644
View file @
650fd1a8
---
title
:
Adjusts suggestions unable to be applied
merge_request
:
24603
author
:
type
:
fixed
spec/services/suggestions/apply_service_spec.rb
View file @
650fd1a8
...
...
@@ -134,12 +134,11 @@ describe Suggestions::ApplyService do
end
end
context
'when
diff ref from position is different from repo diff refs
'
do
context
'when
HEAD from position is different from source branch HEAD on repo
'
do
it
'returns error message'
do
outdated_refs
=
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
'foo'
,
start_sha:
'bar'
,
head_sha:
'outdated'
)
allow
(
suggestion
).
to
receive
(
:appliable?
)
{
true
}
allow
(
suggestion
.
position
).
to
receive
(
:diff_refs
)
{
outdated_refs
}
allow
(
suggestion
.
position
).
to
receive
(
:head_sha
)
{
'old-sha'
}
allow
(
suggestion
.
noteable
).
to
receive
(
:source_branch_sha
)
{
'new-sha'
}
result
=
subject
.
execute
(
suggestion
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment