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
Jérome Perrin
gitlab-ce
Commits
545a85dc
Commit
545a85dc
authored
Jul 10, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actually render old and new sections of parallel diff next to each other
parent
92772f85
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
103 deletions
+65
-103
CHANGELOG
CHANGELOG
+1
-0
features/steps/shared/diff_note.rb
features/steps/shared/diff_note.rb
+2
-2
lib/gitlab/diff/parallel_diff.rb
lib/gitlab/diff/parallel_diff.rb
+55
-74
spec/fixtures/parallel_diff_result.yml
spec/fixtures/parallel_diff_result.yml
+7
-27
No files found.
CHANGELOG
View file @
545a85dc
...
@@ -33,6 +33,7 @@ v 8.10.0 (unreleased)
...
@@ -33,6 +33,7 @@ v 8.10.0 (unreleased)
- Fix user creation with stronger minimum password requirements !4054 (nathan-pmt)
- Fix user creation with stronger minimum password requirements !4054 (nathan-pmt)
- Only show New Snippet button to users that can create snippets.
- Only show New Snippet button to users that can create snippets.
- PipelinesFinder uses git cache data
- PipelinesFinder uses git cache data
- Actually render old and new sections of parallel diff next to each other
- Throttle the update of `project.pushes_since_gc` to 1 minute.
- Throttle the update of `project.pushes_since_gc` to 1 minute.
- Check for conflicts with existing Project's wiki path when creating a new project.
- Check for conflicts with existing Project's wiki path when creating a new project.
- Show last push widget in upstream after push to fork
- Show last push widget in upstream after push to fork
...
...
features/steps/shared/diff_note.rb
View file @
545a85dc
...
@@ -32,8 +32,8 @@ module SharedDiffNote
...
@@ -32,8 +32,8 @@ module SharedDiffNote
end
end
step
'I leave a diff comment in a parallel view on the left side like "Old comment"'
do
step
'I leave a diff comment in a parallel view on the left side like "Old comment"'
do
click_parallel_diff_line
(
sample_commit
.
line_code
,
'old'
)
click_parallel_diff_line
(
sample_commit
.
del_
line_code
,
'old'
)
page
.
within
(
"
#{
diff_file_selector
}
form[data-line-code='
#{
sample_commit
.
line_code
}
']"
)
do
page
.
within
(
"
#{
diff_file_selector
}
form[data-line-code='
#{
sample_commit
.
del_
line_code
}
']"
)
do
fill_in
"note[note]"
,
with:
"Old comment"
fill_in
"note[note]"
,
with:
"Old comment"
find
(
".js-comment-button"
).
trigger
(
"click"
)
find
(
".js-comment-button"
).
trigger
(
"click"
)
end
end
...
...
lib/gitlab/diff/parallel_diff.rb
View file @
545a85dc
...
@@ -8,95 +8,78 @@ module Gitlab
...
@@ -8,95 +8,78 @@ module Gitlab
end
end
def
parallelize
def
parallelize
lines
=
[]
skip_next
=
false
i
=
0
free_right_index
=
nil
lines
=
[]
highlighted_diff_lines
=
diff_file
.
highlighted_diff_lines
highlighted_diff_lines
=
diff_file
.
highlighted_diff_lines
highlighted_diff_lines
.
each
do
|
line
|
highlighted_diff_lines
.
each
do
|
line
|
full_line
=
line
.
text
type
=
line
.
type
line_code
=
diff_file
.
line_code
(
line
)
line_code
=
diff_file
.
line_code
(
line
)
line_new
=
line
.
new_pos
line_old
=
line
.
old_pos
position
=
diff_file
.
position
(
line
)
position
=
diff_file
.
position
(
line
)
next_line
=
diff_file
.
next_line
(
line
.
index
)
case
line
.
type
if
next_line
next_line
=
highlighted_diff_lines
[
next_line
.
index
]
full_next_line
=
next_line
.
text
next_line_code
=
diff_file
.
line_code
(
next_line
)
next_type
=
next_line
.
type
next_position
=
diff_file
.
position
(
next_line
)
end
case
type
when
'match'
,
nil
when
'match'
,
nil
# line in the right panel is the same as in the left one
# line in the right panel is the same as in the left one
lines
<<
{
lines
<<
{
left:
{
left:
{
type:
type
,
type:
line
.
type
,
number:
line
_old
,
number:
line
.
old_pos
,
text:
full_line
,
text:
line
.
text
,
line_code:
line_code
,
line_code:
line_code
,
position:
position
position:
position
},
},
right:
{
right:
{
type:
type
,
type:
line
.
type
,
number:
line
_new
,
number:
line
.
new_pos
,
text:
full_line
,
text:
line
.
text
,
line_code:
line_code
,
line_code:
line_code
,
position:
position
position:
position
}
}
}
}
free_right_index
=
nil
i
+=
1
when
'old'
when
'old'
case
next_type
lines
<<
{
when
'new'
left:
{
# Left side has text removed, right side has text added
type:
line
.
type
,
lines
<<
{
number:
line
.
old_pos
,
left:
{
text:
line
.
text
,
type:
type
,
line_code:
line_code
,
number:
line_old
,
position:
position
text:
full_line
,
},
line_code:
line_code
,
right:
{
position:
position
type:
nil
,
},
number:
nil
,
right:
{
text:
""
,
type:
next_type
,
line_code:
line_code
,
number:
line_new
,
position:
position
text:
full_next_line
,
line_code:
next_line_code
,
position:
next_position
,
}
}
skip_next
=
true
when
'old'
,
'nonewline'
,
nil
# Left side has text removed, right side doesn't have any change
# No next line code, no new line number, no new line text
lines
<<
{
left:
{
type:
type
,
number:
line_old
,
text:
full_line
,
line_code:
line_code
,
position:
position
},
right:
{
type:
next_type
,
number:
nil
,
text:
""
,
line_code:
nil
,
position:
nil
}
}
}
end
}
# Once we come upon a new line it can be put on the right of this old line
free_right_index
||=
i
i
+=
1
when
'new'
when
'new'
if
skip_next
data
=
{
# Change has been already included in previous line so no need to do it again
type:
line
.
type
,
skip_next
=
false
number:
line
.
new_pos
,
next
text:
line
.
text
,
line_code:
line_code
,
position:
position
}
if
free_right_index
# If an old line came before this without a line on the right, this
# line can be put to the right of it.
lines
[
free_right_index
][
:right
]
=
data
# If there are any other old lines on the left that don't yet have
# a new counterpart on the right, update the free_right_index
next_free_right_index
=
free_right_index
+
1
free_right_index
=
next_free_right_index
<
i
?
next_free_right_index
:
nil
else
else
# Change is only on the right side, left side has no change
lines
<<
{
lines
<<
{
left:
{
left:
{
type:
nil
,
type:
nil
,
...
@@ -105,17 +88,15 @@ module Gitlab
...
@@ -105,17 +88,15 @@ module Gitlab
line_code:
line_code
,
line_code:
line_code
,
position:
position
position:
position
},
},
right:
{
right:
data
type:
type
,
number:
line_new
,
text:
full_line
,
line_code:
line_code
,
position:
position
}
}
}
free_right_index
=
nil
i
+=
1
end
end
end
end
end
end
lines
lines
end
end
end
end
...
...
spec/fixtures/parallel_diff_result.yml
View file @
545a85dc
...
@@ -252,27 +252,6 @@
...
@@ -252,27 +252,6 @@
:base_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:base_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:start_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:start_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:head_sha: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
:head_sha: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
:right:
:type: old
:number:
:text: ''
:line_code:
:position:
-
:left:
:type: old
:number:
14
:text: |
-<span id="LC14" class="line"> <span class="n">options</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">chdir
:
</span><span class="n">path</span> <span class="p">}</span></span>
:line_code: 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_13
:position: !ruby/object:Gitlab::Diff::Position
attributes
:
:old_path: files/ruby/popen.rb
:new_path: files/ruby/popen.rb
:old_line:
14
:new_line:
:base_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:start_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:head_sha: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
:right:
:right:
:type: new
:type: new
:number:
13
:number:
13
...
@@ -289,16 +268,17 @@
...
@@ -289,16 +268,17 @@
:start_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:start_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:head_sha: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
:head_sha: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
-
:left:
-
:left:
:type:
:type: old
:number:
:number:
14
:text: ''
:text: |
:line_code: 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_14
-<span id="LC14" class="line"> <span class="n">options</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">chdir
:
</span><span class="n">path</span> <span class="p">}</span></span>
:line_code: 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_13
:position: !ruby/object:Gitlab::Diff::Position
:position: !ruby/object:Gitlab::Diff::Position
attributes
:
attributes
:
:old_path: files/ruby/popen.rb
:old_path: files/ruby/popen.rb
:new_path: files/ruby/popen.rb
:new_path: files/ruby/popen.rb
:old_line:
:old_line:
14
:new_line:
14
:new_line:
:base_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:base_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:start_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:start_sha: 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
:head_sha: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
:head_sha: 570e7b2abdd848b95f2f578043fc23bd6f6fd24d
...
...
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