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
8b2e065b
Commit
8b2e065b
authored
Aug 31, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compare merge request version against other version on changes page
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
9b5a8381
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
13 deletions
+34
-13
merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+16
-1
merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+4
-2
_versions.html.haml
app/views/projects/merge_requests/show/_versions.html.haml
+14
-10
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
8b2e065b
...
...
@@ -98,7 +98,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@diff_notes_disabled
=
true
end
@diffs
=
@merge_request_diff
.
diffs
(
diff_options
)
if
params
[
:start_sha
].
present?
compare_diff_version
else
@diffs
=
@merge_request_diff
.
diffs
(
diff_options
)
end
render
json:
{
html:
view_to_html_string
(
"projects/merge_requests/show/_diffs"
)
}
end
...
...
@@ -529,4 +533,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
params
[
:merge_request
]
||=
ActionController
::
Parameters
.
new
(
source_project:
@project
)
@merge_request
=
MergeRequests
::
BuildService
.
new
(
project
,
current_user
,
merge_request_params
).
execute
end
def
compare_diff_version
@compare
=
CompareService
.
new
.
execute
(
@project
,
@merge_request_diff
.
head_commit_sha
,
@project
,
params
[
:start_sha
])
if
@compare
@commits
=
@compare
.
commits
@commit
=
@compare
.
commit
@diffs
=
@compare
.
diffs
(
diff_options
)
@diff_notes_disabled
=
true
end
end
end
app/helpers/merge_requests_helper.rb
View file @
8b2e065b
...
...
@@ -101,7 +101,9 @@ module MergeRequestsHelper
return
'hidden'
if
merge_request
.
closed?
==
closed
||
(
merge_request
.
merged?
==
closed
&&
!
merge_request
.
closed?
)
||
merge_request
.
closed_without_fork?
end
def
compare_versions_path
(
project
,
version
,
base_version
)
namespace_project_compare_path
(
project
.
namespace
,
project
,
base_version
.
head_commit_sha
,
version
.
head_commit_sha
)
def
mr_version_path
(
project
,
merge_request
,
merge_request_diff
,
start_sha
=
nil
)
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
,
diff_id:
merge_request_diff
.
id
,
start_sha:
start_sha
)
end
end
app/views/projects/merge_requests/show/_versions.html.haml
View file @
8b2e065b
...
...
@@ -26,28 +26,32 @@
Compared
with:
%span
.dropdown.inline
%a
.btn-link.dropdown-toggle
{
data:
{
toggle: :dropdown
}
}
%strong
.monospace
base
%strong
.monospace
<
-
if
params
[
:start_sha
].
present?
#{
params
[
:start_sha
][
0
...
8
]
}
-
else
#{
"base"
}
%span
.caret
%ul
.dropdown-menu.dropdown-menu-selectable
-
merge_request_diffs
.
each
do
|
merge_request_diff
|
-
next
if
merge_request_diff
.
id
>=
@merge_request_diff
.
id
%li
=
link_to
compare_versions_path
(
@project
,
@merge_request_diff
,
merge_request_diff
),
class:
(
'is-active'
if
merge_request_diff
==
@base_version
),
target:
'_blank'
do
=
link_to
mr_version_path
(
@project
,
@merge_request
,
@merge_request_diff
,
merge_request_diff
.
head_commit_sha
),
class:
(
'is-active'
if
merge_request_diff
.
head_commit_sha
==
params
[
:start_sha
])
do
%strong
.monospace
#{
merge_request_diff
.
head_commit
.
short_id
}
%br
%small
=
time_ago_with_tooltip
(
merge_request_diff
.
created_at
)
%li
=
link_to
'#'
,
class:
'is-active'
do
=
link_to
mr_version_path
(
@project
,
@merge_request
,
@merge_request_diff
),
class:
(
'is-active'
unless
params
[
:start_sha
].
present?
)
do
%strong
.monospace
base
-
unless
@merge_request_diff
.
latest?
%span
.prepend-left-default
=
icon
(
'info-circle'
)
This
version
is
not
the
latest
one
.
Comments
are
disabled
.pull-right
%span
.monospace
#{
@merge_request_diff
.
base_commit
.
short_id
}
..
#{
@merge_request_diff
.
head_commit
.
short_id
}
-
unless
@merge_request_diff
.
latest?
&&
params
[
:start_sha
].
blank?
.pull-right
=
icon
(
'info-circle'
)
-
if
params
[
:start_sha
].
present?
Comments
are
disabled
when
compare
with
version
different
from
base
-
else
This
version
is
not
the
latest
one
.
Comments
are
disabled
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