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
e50e88b8
Commit
e50e88b8
authored
Aug 03, 2016
by
Sean McGivern
Committed by
Fatih Acet
Aug 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add blob_path to conflict file JSON
parent
3cc07e7e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
+19
-5
lib/gitlab/conflict/file.rb
lib/gitlab/conflict/file.rb
+9
-3
lib/gitlab/conflict/file_collection.rb
lib/gitlab/conflict/file_collection.rb
+1
-1
spec/lib/gitlab/conflict/file_spec.rb
spec/lib/gitlab/conflict/file_spec.rb
+9
-1
No files found.
lib/gitlab/conflict/file.rb
View file @
e50e88b8
module
Gitlab
module
Conflict
class
File
include
Gitlab
::
Routing
.
url_helpers
class
MissingResolution
<
StandardError
end
CONTEXT_LINES
=
3
attr_reader
:merge_file_result
,
:their_path
,
:our_path
,
:repository
attr_reader
:merge_file_result
,
:their_path
,
:our_path
,
:
merge_request
,
:
repository
def
initialize
(
merge_file_result
,
conflict
,
repository
:)
def
initialize
(
merge_file_result
,
conflict
,
merge_request
:)
@merge_file_result
=
merge_file_result
@their_path
=
conflict
[
:theirs
][
:path
]
@our_path
=
conflict
[
:ours
][
:path
]
@repository
=
repository
@merge_request
=
merge_request
@repository
=
merge_request
.
project
.
repository
end
# Array of Gitlab::Diff::Line objects
...
...
@@ -147,6 +150,9 @@ module Gitlab
{
old_path:
their_path
,
new_path:
our_path
,
blob_path:
namespace_project_blob_path
(
merge_request
.
project
.
namespace
,
merge_request
.
project
,
::
File
.
join
(
merge_request
.
diff_refs
.
head_sha
,
our_path
)),
sections:
sections
}
end
...
...
lib/gitlab/conflict/file_collection.rb
View file @
e50e88b8
...
...
@@ -47,7 +47,7 @@ module Gitlab
Gitlab
::
Conflict
::
File
.
new
(
merge_index
.
merge_file
(
conflict
[
:ours
][
:path
]),
conflict
,
repository:
repository
)
merge_request:
merge_request
)
end
end
...
...
spec/lib/gitlab/conflict/file_spec.rb
View file @
e50e88b8
...
...
@@ -6,10 +6,11 @@ describe Gitlab::Conflict::File, lib: true do
let
(
:rugged
)
{
repository
.
rugged
}
let
(
:their_commit
)
{
rugged
.
branches
[
'conflict-a'
].
target
}
let
(
:our_commit
)
{
rugged
.
branches
[
'conflict-b'
].
target
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_branch:
'conflict-b'
,
target_branch:
'conflict-a'
,
source_project:
project
)
}
let
(
:index
)
{
rugged
.
merge_commits
(
our_commit
,
their_commit
)
}
let
(
:conflict
)
{
index
.
conflicts
.
last
}
let
(
:merge_file_result
)
{
index
.
merge_file
(
'files/ruby/regex.rb'
)
}
let
(
:conflict_file
)
{
Gitlab
::
Conflict
::
File
.
new
(
merge_file_result
,
conflict
,
repository:
repository
)
}
let
(
:conflict_file
)
{
Gitlab
::
Conflict
::
File
.
new
(
merge_file_result
,
conflict
,
merge_request:
merge_request
)
}
describe
'#resolve_lines'
do
let
(
:section_keys
)
{
conflict_file
.
sections
.
map
{
|
section
|
section
[
:id
]
}.
compact
}
...
...
@@ -141,4 +142,11 @@ describe Gitlab::Conflict::File, lib: true do
expect
(
section_ids
.
uniq
).
to
eq
(
section_ids
)
end
end
describe
'#as_json'
do
it
'includes the blob path for the file'
do
expect
(
conflict_file
.
as_json
[
:blob_path
]).
to
eq
(
"/
#{
project
.
namespace
.
to_param
}
/
#{
merge_request
.
project
.
to_param
}
/blob/
#{
our_commit
.
oid
}
/files/ruby/regex.rb"
)
end
end
end
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