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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
3b84cfdc
Commit
3b84cfdc
authored
Aug 02, 2016
by
Sean McGivern
Committed by
Fatih Acet
Aug 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use same resolution format on FE and BE
parent
76cd67b0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
18 deletions
+20
-18
app/assets/javascripts/merge_conflict_data_provider.js.es6
app/assets/javascripts/merge_conflict_data_provider.js.es6
+1
-1
lib/gitlab/conflict/file.rb
lib/gitlab/conflict/file.rb
+2
-2
lib/gitlab/conflict/file_collection.rb
lib/gitlab/conflict/file_collection.rb
+3
-2
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+12
-11
spec/lib/gitlab/conflict/file_spec.rb
spec/lib/gitlab/conflict/file_spec.rb
+2
-2
No files found.
app/assets/javascripts/merge_conflict_data_provider.js.es6
View file @
3b84cfdc
...
@@ -287,7 +287,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
...
@@ -287,7 +287,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
getCommitData() {
getCommitData() {
return {
return {
commit
M
essage: this.vueInstance.conflictsData.commitMessage,
commit
_m
essage: this.vueInstance.conflictsData.commitMessage,
sections: this.vueInstance.resolutionData
sections: this.vueInstance.resolutionData
}
}
}
}
...
...
lib/gitlab/conflict/file.rb
View file @
3b84cfdc
...
@@ -44,9 +44,9 @@ module Gitlab
...
@@ -44,9 +44,9 @@ module Gitlab
section_id
||=
line_code
(
line
)
section_id
||=
line_code
(
line
)
case
resolution
[
section_id
]
case
resolution
[
section_id
]
when
'
ours
'
when
'
head
'
next
unless
line
.
type
==
'new'
next
unless
line
.
type
==
'new'
when
'
theirs
'
when
'
origin
'
next
unless
line
.
type
==
'old'
next
unless
line
.
type
==
'old'
else
else
raise
MissingResolution
,
"Missing resolution for section ID:
#{
section_id
}
"
raise
MissingResolution
,
"Missing resolution for section ID:
#{
section_id
}
"
...
...
lib/gitlab/conflict/file_collection.rb
View file @
3b84cfdc
...
@@ -20,10 +20,11 @@ module Gitlab
...
@@ -20,10 +20,11 @@ module Gitlab
@merge_index
||=
repository
.
rugged
.
merge_commits
(
our_commit
,
their_commit
)
@merge_index
||=
repository
.
rugged
.
merge_commits
(
our_commit
,
their_commit
)
end
end
def
resolve_conflicts!
(
resolutions
,
commit_message
,
user
:)
def
resolve_conflicts!
(
params
,
user
:)
resolutions
=
params
[
:sections
]
commit_message
=
params
[
:commit_message
]
||
default_commit_message
rugged
=
repository
.
rugged
rugged
=
repository
.
rugged
committer
=
repository
.
user_to_committer
(
user
)
committer
=
repository
.
user_to_committer
(
user
)
commit_message
||=
default_commit_message
files
.
each
do
|
file
|
files
.
each
do
|
file
|
file
.
resolve!
(
resolutions
,
index:
merge_index
,
rugged:
rugged
)
file
.
resolve!
(
resolutions
,
index:
merge_index
,
rugged:
rugged
)
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
3b84cfdc
...
@@ -549,7 +549,7 @@ describe Projects::MergeRequestsController do
...
@@ -549,7 +549,7 @@ describe Projects::MergeRequestsController do
end
end
it
'returns JSON with a message'
do
it
'returns JSON with a message'
do
expect
(
json_response
.
keys
).
to
contain_exactly
(
'message'
)
expect
(
json_response
.
keys
).
to
contain_exactly
(
'message'
,
'type'
)
end
end
end
end
...
@@ -613,30 +613,31 @@ describe Projects::MergeRequestsController do
...
@@ -613,30 +613,31 @@ describe Projects::MergeRequestsController do
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
let!
(
:original_head_sha
)
{
merge_request_with_conflicts
.
diff_head_sha
}
let!
(
:original_head_sha
)
{
merge_request_with_conflicts
.
diff_head_sha
}
def
resolve_conflicts
(
param
s
)
def
resolve_conflicts
(
section
s
)
post
:resolve_conflicts
,
post
:resolve_conflicts
,
namespace_id:
merge_request_with_conflicts
.
project
.
namespace
.
to_param
,
namespace_id:
merge_request_with_conflicts
.
project
.
namespace
.
to_param
,
project_id:
merge_request_with_conflicts
.
project
.
to_param
,
project_id:
merge_request_with_conflicts
.
project
.
to_param
,
id:
merge_request_with_conflicts
.
iid
,
id:
merge_request_with_conflicts
.
iid
,
format:
'json'
,
format:
'json'
,
merge_request:
params
sections:
sections
,
commit_message:
'Commit message'
end
end
context
'with valid params'
do
context
'with valid params'
do
before
do
before
do
resolve_conflicts
(
'2f6fcd96b88b36ce98c38da085c795a27d92a3dd_4_4'
=>
'
ours
'
,
resolve_conflicts
(
'2f6fcd96b88b36ce98c38da085c795a27d92a3dd_4_4'
=>
'
head
'
,
'6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9'
=>
'
ours
'
,
'6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9'
=>
'
head
'
,
'6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21'
=>
'
theirs
'
,
'6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21'
=>
'
origin
'
,
'6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49'
=>
'
theirs
'
)
'6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49'
=>
'
origin
'
)
end
end
it
'creates a new commit on the branch'
do
it
'creates a new commit on the branch'
do
expect
(
original_head_sha
).
not_to
eq
(
merge_request_with_conflicts
.
source_branch_head
.
sha
)
expect
(
original_head_sha
).
not_to
eq
(
merge_request_with_conflicts
.
source_branch_head
.
sha
)
expect
(
merge_request_with_conflicts
.
source_branch_head
.
message
).
to
include
(
'
Merge branch
'
)
expect
(
merge_request_with_conflicts
.
source_branch_head
.
message
).
to
include
(
'
Commit message
'
)
end
end
it
're
directs to the MR show pag
e'
do
it
're
turns an OK resposn
e'
do
expect
(
response
).
to
redirect_to
([
merge_request_with_conflicts
.
target_project
.
namespace
.
becomes
(
Namespace
),
merge_request_with_conflicts
.
target_project
,
merge_request_with_conflicts
]
)
expect
(
response
).
to
have_http_status
(
:ok
)
end
end
context
'undoing the resolution'
do
context
'undoing the resolution'
do
...
@@ -655,7 +656,7 @@ describe Projects::MergeRequestsController do
...
@@ -655,7 +656,7 @@ describe Projects::MergeRequestsController do
context
'when sections are missing'
do
context
'when sections are missing'
do
before
do
before
do
resolve_conflicts
(
'2f6fcd96b88b36ce98c38da085c795a27d92a3dd_4_4'
=>
'
ours
'
)
resolve_conflicts
(
'2f6fcd96b88b36ce98c38da085c795a27d92a3dd_4_4'
=>
'
head
'
)
end
end
it
'returns a 400 error'
do
it
'returns a 400 error'
do
...
...
spec/lib/gitlab/conflict/file_spec.rb
View file @
3b84cfdc
...
@@ -15,7 +15,7 @@ describe Gitlab::Conflict::File, lib: true do
...
@@ -15,7 +15,7 @@ describe Gitlab::Conflict::File, lib: true do
let
(
:section_keys
)
{
conflict_file
.
sections
.
map
{
|
section
|
section
[
:id
]
}.
compact
}
let
(
:section_keys
)
{
conflict_file
.
sections
.
map
{
|
section
|
section
[
:id
]
}.
compact
}
context
'when resolving everything to the same side'
do
context
'when resolving everything to the same side'
do
let
(
:resolution_hash
)
{
section_keys
.
map
{
|
key
|
[
key
,
'
ours
'
]
}.
to_h
}
let
(
:resolution_hash
)
{
section_keys
.
map
{
|
key
|
[
key
,
'
head
'
]
}.
to_h
}
let
(
:resolved_lines
)
{
conflict_file
.
resolve_lines
(
resolution_hash
)
}
let
(
:resolved_lines
)
{
conflict_file
.
resolve_lines
(
resolution_hash
)
}
let
(
:expected_lines
)
{
conflict_file
.
lines
.
reject
{
|
line
|
line
.
type
==
'old'
}
}
let
(
:expected_lines
)
{
conflict_file
.
lines
.
reject
{
|
line
|
line
.
type
==
'old'
}
}
...
@@ -30,7 +30,7 @@ describe Gitlab::Conflict::File, lib: true do
...
@@ -30,7 +30,7 @@ describe Gitlab::Conflict::File, lib: true do
context
'with mixed resolutions'
do
context
'with mixed resolutions'
do
let
(
:resolution_hash
)
do
let
(
:resolution_hash
)
do
section_keys
.
map
.
with_index
{
|
key
,
i
|
[
key
,
i
.
even?
?
'
ours'
:
'theirs
'
]
}.
to_h
section_keys
.
map
.
with_index
{
|
key
,
i
|
[
key
,
i
.
even?
?
'
head'
:
'origin
'
]
}.
to_h
end
end
let
(
:resolved_lines
)
{
conflict_file
.
resolve_lines
(
resolution_hash
)
}
let
(
:resolved_lines
)
{
conflict_file
.
resolve_lines
(
resolution_hash
)
}
...
...
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