BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
643a368f
Unverified
Commit
643a368f
authored
Aug 15, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make merge request diff works with new FileCollection logic
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
5e95c0b8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
17 deletions
+22
-17
merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
merge_request.rb
app/models/merge_request.rb
+3
-3
merge_request_diff.rb
app/models/merge_request_diff.rb
+9
-5
_diffs.html.haml
app/views/projects/merge_requests/show/_diffs.html.haml
+1
-0
merge_request_diff.rb
lib/gitlab/diff/file_collection/merge_request_diff.rb
+8
-8
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
643a368f
...
...
@@ -91,7 +91,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
respond_to
do
|
format
|
format
.
html
{
define_discussion_vars
}
format
.
json
do
@diffs
=
@merge_request
.
diffs
(
diff_options
)
@diffs
=
@merge_request
_diff
.
diffs
(
diff_options
)
render
json:
{
html:
view_to_html_string
(
"projects/merge_requests/show/_diffs"
)
}
end
...
...
app/models/merge_request.rb
View file @
643a368f
...
...
@@ -172,10 +172,10 @@ class MergeRequest < ActiveRecord::Base
end
def
diffs
(
diff_options
=
nil
)
if
self
.
compare
self
.
compare
.
diffs
(
diff_options
)
if
compare
compare
.
diffs
(
diff_options
)
else
Gitlab
::
Diff
::
FileCollection
::
MergeRequest
.
new
(
self
,
diff_options:
diff_options
)
merge_request_diff
.
diffs
(
diff_options
)
end
end
...
...
app/models/merge_request_diff.rb
View file @
643a368f
...
...
@@ -141,7 +141,13 @@ class MergeRequestDiff < ActiveRecord::Base
base_commit_sha?
&&
head_commit_sha?
&&
start_commit_sha?
end
private
def
diffs
(
diff_options
=
nil
)
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiff
.
new
(
self
,
diff_options:
diff_options
)
end
def
project
merge_request
.
target_project
end
def
compare
@compare
||=
...
...
@@ -157,6 +163,8 @@ class MergeRequestDiff < ActiveRecord::Base
end
end
private
def
dump_commits
(
commits
)
commits
.
map
(
&
:to_hash
)
end
...
...
@@ -229,10 +237,6 @@ class MergeRequestDiff < ActiveRecord::Base
update_columns_serialized
(
new_attributes
)
end
def
project
merge_request
.
target_project
end
def
repository
project
.
repository
end
...
...
app/views/projects/merge_requests/show/_diffs.html.haml
View file @
643a368f
-
if
@merge_request_diff
.
collected?
=
render
'projects/merge_requests/show/versions'
=
render
"projects/diffs/diffs"
,
diffs:
@diffs
-
elsif
@merge_request_diff
.
empty?
.nothing-here-block
Nothing to merge from
#{
@merge_request
.
source_branch
}
into
#{
@merge_request
.
target_branch
}
...
...
lib/gitlab/diff/file_collection/merge_request.rb
→
lib/gitlab/diff/file_collection/merge_request
_diff
.rb
View file @
643a368f
module
Gitlab
module
Diff
module
FileCollection
class
MergeRequest
<
Base
def
initialize
(
merge_request
,
diff_options
:)
@merge_request
=
merge_request
class
MergeRequest
Diff
<
Base
def
initialize
(
merge_request
_diff
,
diff_options
:)
@merge_request
_diff
=
merge_request_diff
super
(
merge_request
,
project:
merge_request
.
project
,
super
(
merge_request
_diff
,
project:
merge_request
_diff
.
project
,
diff_options:
diff_options
,
diff_refs:
merge_request
.
diff_refs
)
diff_refs:
merge_request
_diff
.
diff_refs
)
end
def
diff_files
...
...
@@ -61,11 +61,11 @@ module Gitlab
end
def
cacheable?
@merge_request
.
merge_request
_diff
.
present?
@merge_request_diff
.
present?
end
def
cache_key
[
@merge_request
.
merge_request
_diff
,
'highlighted-diff-files'
,
diff_options
]
[
@merge_request_diff
,
'highlighted-diff-files'
,
diff_options
]
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