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
Boxiang Sun
gitlab-ce
Commits
b202b42c
Commit
b202b42c
authored
Mar 31, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Link to outdated diff in older MR version from outdated diff discussion
parent
3d1cade1
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
63 additions
and
39 deletions
+63
-39
app/assets/stylesheets/pages/merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+2
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+11
-17
app/models/concerns/note_on_diff.rb
app/models/concerns/note_on_diff.rb
+10
-0
app/models/concerns/noteable.rb
app/models/concerns/noteable.rb
+2
-2
app/models/diff_discussion.rb
app/models/diff_discussion.rb
+1
-0
app/models/diff_note.rb
app/models/diff_note.rb
+6
-8
app/models/legacy_diff_note.rb
app/models/legacy_diff_note.rb
+2
-1
app/models/merge_request.rb
app/models/merge_request.rb
+4
-0
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+1
-0
app/models/note.rb
app/models/note.rb
+6
-2
app/views/discussions/_discussion.html.haml
app/views/discussions/_discussion.html.haml
+6
-1
app/views/projects/diffs/_parallel_view.html.haml
app/views/projects/diffs/_parallel_view.html.haml
+1
-2
app/views/projects/diffs/_text_file.html.haml
app/views/projects/diffs/_text_file.html.haml
+1
-2
app/views/projects/merge_requests/show/_versions.html.haml
app/views/projects/merge_requests/show/_versions.html.haml
+6
-4
changelogs/unreleased/dm-link-discussion-to-outdated-diff.yml
...gelogs/unreleased/dm-link-discussion-to-outdated-diff.yml
+4
-0
No files found.
app/assets/stylesheets/pages/merge_requests.scss
View file @
b202b42c
...
@@ -528,6 +528,8 @@
...
@@ -528,6 +528,8 @@
}
}
.comments-disabled-notif
{
.comments-disabled-notif
{
line-height
:
28px
;
.btn
{
.btn
{
margin-left
:
5px
;
margin-left
:
5px
;
}
}
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
b202b42c
...
@@ -16,7 +16,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -16,7 +16,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action
:define_show_vars
,
only:
[
:show
,
:diffs
,
:commits
,
:conflicts
,
:conflict_for_path
,
:builds
,
:pipelines
]
before_action
:define_show_vars
,
only:
[
:show
,
:diffs
,
:commits
,
:conflicts
,
:conflict_for_path
,
:builds
,
:pipelines
]
before_action
:define_widget_vars
,
only:
[
:merge
,
:cancel_merge_when_pipeline_succeeds
,
:merge_check
]
before_action
:define_widget_vars
,
only:
[
:merge
,
:cancel_merge_when_pipeline_succeeds
,
:merge_check
]
before_action
:define_commit_vars
,
only:
[
:diffs
]
before_action
:define_commit_vars
,
only:
[
:diffs
]
before_action
:define_diff_comment_vars
,
only:
[
:diffs
]
before_action
:ensure_ref_fetched
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
,
:conflicts
,
:conflict_for_path
,
:pipelines
]
before_action
:ensure_ref_fetched
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
,
:conflicts
,
:conflict_for_path
,
:pipelines
]
before_action
:close_merge_request_without_source_project
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
,
:pipelines
]
before_action
:close_merge_request_without_source_project
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
,
:pipelines
]
before_action
:apply_diff_view_cookie!
,
only:
[
:new_diffs
]
before_action
:apply_diff_view_cookie!
,
only:
[
:new_diffs
]
...
@@ -108,6 +107,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -108,6 +107,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request
.
merge_request_diff
@merge_request
.
merge_request_diff
end
end
define_diff_comment_vars
@merge_request_diffs
=
@merge_request
.
merge_request_diffs
.
viewable
.
select_without_diff
@merge_request_diffs
=
@merge_request
.
merge_request_diffs
.
viewable
.
select_without_diff
@comparable_diffs
=
@merge_request_diffs
.
select
{
|
diff
|
diff
.
id
<
@merge_request_diff
.
id
}
@comparable_diffs
=
@merge_request_diffs
.
select
{
|
diff
|
diff
.
id
<
@merge_request_diff
.
id
}
...
@@ -123,11 +124,14 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -123,11 +124,14 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@environment
=
@merge_request
.
environments_for
(
current_user
).
last
@environment
=
@merge_request
.
environments_for
(
current_user
).
last
if
@start_sha
@diff_notes_disabled
=
!
@merge_request_diff
.
latest?
||
@start_sha
compared_diff_version
else
@diffs
=
original_diff_version
if
@start_sha
end
@merge_request_diff
.
compare_with
(
@start_sha
).
diffs
(
diff_options
)
else
@merge_request_diff
.
diffs
(
diff_options
)
end
render
json:
{
html:
view_to_html_string
(
"projects/merge_requests/show/_diffs"
)
}
render
json:
{
html:
view_to_html_string
(
"projects/merge_requests/show/_diffs"
)
}
end
end
...
@@ -594,7 +598,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -594,7 +598,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@use_legacy_diff_notes
=
!
@merge_request
.
has_complete_diff_refs?
@use_legacy_diff_notes
=
!
@merge_request
.
has_complete_diff_refs?
@grouped_diff_discussions
=
@merge_request
.
grouped_diff_discussions
@grouped_diff_discussions
=
@merge_request
.
grouped_diff_discussions
(
@merge_request_diff
.
diff_refs
)
@notes
=
prepare_notes_for_rendering
(
@grouped_diff_discussions
.
values
.
flatten
.
flat_map
(
&
:notes
))
@notes
=
prepare_notes_for_rendering
(
@grouped_diff_discussions
.
values
.
flatten
.
flat_map
(
&
:notes
))
end
end
...
@@ -678,16 +682,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -678,16 +682,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request
=
MergeRequests
::
BuildService
.
new
(
project
,
current_user
,
merge_request_params
.
merge
(
diff_options:
diff_options
)).
execute
@merge_request
=
MergeRequests
::
BuildService
.
new
(
project
,
current_user
,
merge_request_params
.
merge
(
diff_options:
diff_options
)).
execute
end
end
def
compared_diff_version
@diff_notes_disabled
=
true
@diffs
=
@merge_request_diff
.
compare_with
(
@start_sha
).
diffs
(
diff_options
)
end
def
original_diff_version
@diff_notes_disabled
=
!
@merge_request_diff
.
latest?
@diffs
=
@merge_request_diff
.
diffs
(
diff_options
)
end
def
close_merge_request_without_source_project
def
close_merge_request_without_source_project
if
!
@merge_request
.
source_project
&&
@merge_request
.
open?
if
!
@merge_request
.
source_project
&&
@merge_request
.
open?
@merge_request
.
close
@merge_request
.
close
...
...
app/models/concerns/note_on_diff.rb
View file @
b202b42c
...
@@ -25,4 +25,14 @@ module NoteOnDiff
...
@@ -25,4 +25,14 @@ module NoteOnDiff
def
diff_attributes
def
diff_attributes
raise
NotImplementedError
raise
NotImplementedError
end
end
private
def
noteable_diff_refs
if
noteable
.
respond_to?
(
:diff_sha_refs
)
noteable
.
diff_sha_refs
else
noteable
.
diff_refs
end
end
end
end
app/models/concerns/noteable.rb
View file @
b202b42c
...
@@ -36,10 +36,10 @@ module Noteable
...
@@ -36,10 +36,10 @@ module Noteable
.
discussions
(
self
)
.
discussions
(
self
)
end
end
def
grouped_diff_discussions
def
grouped_diff_discussions
(
*
args
)
# Doesn't use `discussion_notes`, because this may include commit diff notes
# Doesn't use `discussion_notes`, because this may include commit diff notes
# besides MR diff notes, that we do no want to display on the MR Changes tab.
# besides MR diff notes, that we do no want to display on the MR Changes tab.
notes
.
inc_relations_for_view
.
grouped_diff_discussions
notes
.
inc_relations_for_view
.
grouped_diff_discussions
(
*
args
)
end
end
def
resolvable_discussions
def
resolvable_discussions
...
...
app/models/diff_discussion.rb
View file @
b202b42c
...
@@ -10,6 +10,7 @@ class DiffDiscussion < Discussion
...
@@ -10,6 +10,7 @@ class DiffDiscussion < Discussion
delegate
:position
,
delegate
:position
,
:original_position
,
:original_position
,
:latest_merge_request_diff
,
to: :first_note
to: :first_note
...
...
app/models/diff_note.rb
View file @
b202b42c
...
@@ -65,20 +65,18 @@ class DiffNote < Note
...
@@ -65,20 +65,18 @@ class DiffNote < Note
self
.
position
.
diff_refs
==
diff_refs
self
.
position
.
diff_refs
==
diff_refs
end
end
def
latest_merge_request_diff
return
unless
for_merge_request?
self
.
noteable
.
merge_request_diff_for
(
self
.
position
.
diff_refs
)
end
private
private
def
supported?
def
supported?
for_commit?
||
self
.
noteable
.
has_complete_diff_refs?
for_commit?
||
self
.
noteable
.
has_complete_diff_refs?
end
end
def
noteable_diff_refs
if
noteable
.
respond_to?
(
:diff_sha_refs
)
noteable
.
diff_sha_refs
else
noteable
.
diff_refs
end
end
def
set_original_position
def
set_original_position
self
.
original_position
=
self
.
position
.
dup
unless
self
.
original_position
&
.
complete?
self
.
original_position
=
self
.
position
.
dup
unless
self
.
original_position
&
.
complete?
end
end
...
...
app/models/legacy_diff_note.rb
View file @
b202b42c
...
@@ -56,11 +56,12 @@ class LegacyDiffNote < Note
...
@@ -56,11 +56,12 @@ class LegacyDiffNote < Note
#
#
# If the note's current diff cannot be matched in the MergeRequest's current
# If the note's current diff cannot be matched in the MergeRequest's current
# diff, it's considered inactive.
# diff, it's considered inactive.
def
active?
def
active?
(
diff_refs
=
nil
)
return
@active
if
defined?
(
@active
)
return
@active
if
defined?
(
@active
)
return
true
if
for_commit?
return
true
if
for_commit?
return
true
unless
diff_line
return
true
unless
diff_line
return
false
unless
noteable
return
false
unless
noteable
return
false
if
diff_refs
&&
diff_refs
!=
noteable_diff_refs
noteable_diff
=
find_noteable_diff
noteable_diff
=
find_noteable_diff
...
...
app/models/merge_request.rb
View file @
b202b42c
...
@@ -367,6 +367,10 @@ class MergeRequest < ActiveRecord::Base
...
@@ -367,6 +367,10 @@ class MergeRequest < ActiveRecord::Base
merge_request_diff
(
true
)
merge_request_diff
(
true
)
end
end
def
merge_request_diff_for
(
diff_refs
)
merge_request_diffs
.
viewable
.
select_without_diff
.
with_diff_refs
(
diff_refs
).
take
end
def
reload_diff_if_branch_changed
def
reload_diff_if_branch_changed
if
source_branch_changed?
||
target_branch_changed?
if
source_branch_changed?
||
target_branch_changed?
reload_diff
reload_diff
...
...
app/models/merge_request_diff.rb
View file @
b202b42c
...
@@ -26,6 +26,7 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -26,6 +26,7 @@ class MergeRequestDiff < ActiveRecord::Base
end
end
scope
:viewable
,
->
{
without_state
(
:empty
)
}
scope
:viewable
,
->
{
without_state
(
:empty
)
}
scope
:with_diff_refs
,
->
(
diff_refs
)
{
where
(
start_commit_sha:
diff_refs
.
start_sha
,
head_commit_sha:
diff_refs
.
head_sha
,
base_commit_sha:
diff_refs
.
base_sha
)
}
# All diff information is collected from repository after object is created.
# All diff information is collected from repository after object is created.
# It allows you to override variables like head_commit_sha before getting diff.
# It allows you to override variables like head_commit_sha before getting diff.
...
...
app/models/note.rb
View file @
b202b42c
...
@@ -113,11 +113,11 @@ class Note < ActiveRecord::Base
...
@@ -113,11 +113,11 @@ class Note < ActiveRecord::Base
Discussion
.
build
(
notes
)
Discussion
.
build
(
notes
)
end
end
def
grouped_diff_discussions
def
grouped_diff_discussions
(
diff_refs
=
nil
)
diff_notes
.
diff_notes
.
fresh
.
fresh
.
discussions
.
discussions
.
select
(
&
:active?
)
.
select
{
|
n
|
n
.
active?
(
diff_refs
)
}
.
group_by
(
&
:line_code
)
group_by
(
&
:line_code
)
end
end
...
@@ -140,6 +140,10 @@ class Note < ActiveRecord::Base
...
@@ -140,6 +140,10 @@ class Note < ActiveRecord::Base
true
true
end
end
def
latest_merge_request_diff
nil
end
def
max_attachment_size
def
max_attachment_size
current_application_settings
.
max_attachment_size
.
megabytes
.
to_i
current_application_settings
.
max_attachment_size
.
megabytes
.
to_i
end
end
...
...
app/views/discussions/_discussion.html.haml
View file @
b202b42c
...
@@ -34,7 +34,12 @@
...
@@ -34,7 +34,12 @@
-
if
discussion
.
active?
-
if
discussion
.
active?
=
link_to
'the diff'
,
discussion_diff_path
(
discussion
)
=
link_to
'the diff'
,
discussion_diff_path
(
discussion
)
-
else
-
else
an outdated diff
-
merge_request_diff
=
discussion
.
latest_merge_request_diff
-
if
merge_request_diff
=
link_to
diffs_namespace_project_merge_request_path
(
discussion
.
project
.
namespace
,
discussion
.
project
,
discussion
.
noteable
,
diff_id:
merge_request_diff
,
anchor:
discussion
.
line_code
)
do
an outdated diff
-
else
an outdated diff
=
time_ago_with_tooltip
(
discussion
.
created_at
,
placement:
"bottom"
,
html_class:
"note-created-ago"
)
=
time_ago_with_tooltip
(
discussion
.
created_at
,
placement:
"bottom"
,
html_class:
"note-created-ago"
)
=
render
"discussions/headline"
,
discussion:
discussion
=
render
"discussions/headline"
,
discussion:
discussion
...
...
app/views/projects/diffs/_parallel_view.html.haml
View file @
b202b42c
...
@@ -5,8 +5,7 @@
...
@@ -5,8 +5,7 @@
-
left
=
line
[
:left
]
-
left
=
line
[
:left
]
-
right
=
line
[
:right
]
-
right
=
line
[
:right
]
-
last_line
=
right
.
new_pos
if
right
-
last_line
=
right
.
new_pos
if
right
-
unless
@diff_notes_disabled
-
discussions_left
,
discussions_right
=
parallel_diff_discussions
(
left
,
right
,
diff_file
)
-
discussions_left
,
discussions_right
=
parallel_diff_discussions
(
left
,
right
,
diff_file
)
%tr
.line_holder.parallel
%tr
.line_holder.parallel
-
if
left
-
if
left
-
case
left
.
type
-
case
left
.
type
...
...
app/views/projects/diffs/_text_file.html.haml
View file @
b202b42c
...
@@ -4,11 +4,10 @@
...
@@ -4,11 +4,10 @@
%a
.show-suppressed-diff.js-show-suppressed-diff
Changes suppressed. Click to show.
%a
.show-suppressed-diff.js-show-suppressed-diff
Changes suppressed. Click to show.
%table
.text-file.code.js-syntax-highlight
{
data:
diff_view_data
,
class:
too_big
?
'hide'
:
''
}
%table
.text-file.code.js-syntax-highlight
{
data:
diff_view_data
,
class:
too_big
?
'hide'
:
''
}
-
discussions
=
@grouped_diff_discussions
unless
@diff_notes_disabled
=
render
partial:
"projects/diffs/line"
,
=
render
partial:
"projects/diffs/line"
,
collection:
diff_file
.
highlighted_diff_lines
,
collection:
diff_file
.
highlighted_diff_lines
,
as: :line
,
as: :line
,
locals:
{
diff_file:
diff_file
,
discussions:
discussions
}
locals:
{
diff_file:
diff_file
,
discussions:
@grouped_diff_
discussions
}
-
if
!
diff_file
.
new_file
&&
!
diff_file
.
deleted_file
&&
diff_file
.
highlighted_diff_lines
.
any?
-
if
!
diff_file
.
new_file
&&
!
diff_file
.
deleted_file
&&
diff_file
.
highlighted_diff_lines
.
any?
-
last_line
=
diff_file
.
highlighted_diff_lines
.
last
-
last_line
=
diff_file
.
highlighted_diff_lines
.
last
...
...
app/views/projects/merge_requests/show/_versions.html.haml
View file @
b202b42c
...
@@ -74,11 +74,13 @@
...
@@ -74,11 +74,13 @@
from
from
%code
=
@merge_request
.
target_branch
%code
=
@merge_request
.
target_branch
-
unless
@merge_request_diff
.
latest?
&&
!
@start_sha
-
if
@diff_notes_disabled
.comments-disabled-notif.content-block
.comments-disabled-notif.content-block
=
icon
(
'info-circle'
)
=
icon
(
'info-circle'
)
-
if
@start_sha
-
if
@start_sha
Comment
s are
disabled because you're comparing two versions of this merge request.
Comment
creation is
disabled because you're comparing two versions of this merge request.
-
else
-
else
Comments are disabled because you're viewing an old version of this merge request.
Discussions on this old version of the merge request are displayed but comment creation has been disabled.
=
link_to
'Show latest version'
,
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
class:
'btn btn-sm'
.pull-right
=
link_to
'Show latest version'
,
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
class:
'btn btn-sm'
changelogs/unreleased/dm-link-discussion-to-outdated-diff.yml
0 → 100644
View file @
b202b42c
---
title
:
Link to outdated diff in older MR version from outdated diff discussion
merge_request
:
author
:
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