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
Léo-Paul Géneau
gitlab-ce
Commits
e84861d5
Commit
e84861d5
authored
Sep 12, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unecesarry array operations.
parent
5564fe31
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
17 deletions
+16
-17
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+9
-9
app/views/projects/diffs/_parallel_view.html.haml
app/views/projects/diffs/_parallel_view.html.haml
+6
-6
app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml
.../projects/notes/_diff_notes_with_reply_parallel.html.haml
+1
-2
No files found.
app/helpers/diff_helper.rb
View file @
e84861d5
...
@@ -36,7 +36,10 @@ module DiffHelper
...
@@ -36,7 +36,10 @@ module DiffHelper
# Building array of lines
# Building array of lines
#
#
# [left_type, left_line_number, left_line_content, line_code, right_line_type, right_line_number, right_line_content]
# [
# left_type, left_line_number, left_line_content, left_line_code,
# right_line_type, right_line_number, right_line_content, right_line_code
# ]
#
#
diff_file
.
diff_lines
.
each
do
|
line
|
diff_file
.
diff_lines
.
each
do
|
line
|
...
@@ -54,23 +57,20 @@ module DiffHelper
...
@@ -54,23 +57,20 @@ module DiffHelper
next_line
=
next_line
.
text
next_line
=
next_line
.
text
end
end
line
=
[
type
,
line_old
,
full_line
,
line_code
,
next_line_code
,
next_type
,
line_new
]
if
type
==
'match'
||
type
.
nil?
if
type
==
'match'
||
type
.
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
line
=
[
type
,
line_old
,
full_line
,
line_code
,
line_code
,
type
,
line_new
,
full_lin
e
]
line
=
[
type
,
line_old
,
full_line
,
line_code
,
type
,
line_new
,
full_line
,
line_cod
e
]
lines
.
push
(
line
)
lines
.
push
(
line
)
elsif
type
==
'old'
elsif
type
==
'old'
if
next_type
==
'new'
if
next_type
==
'new'
# Left side has text removed, right side has text added
# Left side has text removed, right side has text added
line
.
push
(
next_line
)
line
=
[
type
,
line_old
,
full_line
,
line_code
,
next_type
,
line_new
,
next_line
,
next_line_code
]
lines
.
push
(
line
)
lines
.
push
(
line
)
skip_next
=
true
skip_next
=
true
elsif
next_type
==
'old'
||
next_type
.
nil?
elsif
next_type
==
'old'
||
next_type
.
nil?
# Left side has text removed, right side doesn't have any change
# Left side has text removed, right side doesn't have any change
line
.
pop
# remove the newline
# No next line code, no new line number, no new line text
line
.
push
(
nil
)
# no line number on the right panel
line
=
[
type
,
line_old
,
full_line
,
line_code
,
next_type
,
nil
,
" "
,
nil
]
line
.
push
(
" "
)
# empty line on the right panel
lines
.
push
(
line
)
lines
.
push
(
line
)
end
end
elsif
type
==
'new'
elsif
type
==
'new'
...
@@ -80,7 +80,7 @@ module DiffHelper
...
@@ -80,7 +80,7 @@ module DiffHelper
next
next
else
else
# Change is only on the right side, left side has no change
# Change is only on the right side, left side has no change
line
=
[
nil
,
nil
,
" "
,
line_code
,
line_code
,
type
,
line_new
,
full_lin
e
]
line
=
[
nil
,
nil
,
" "
,
line_code
,
type
,
line_new
,
full_line
,
line_cod
e
]
lines
.
push
(
line
)
lines
.
push
(
line
)
end
end
end
end
...
...
app/views/projects/diffs/_parallel_view.html.haml
View file @
e84861d5
...
@@ -6,10 +6,10 @@
...
@@ -6,10 +6,10 @@
-
line_number_left
=
line
[
1
]
-
line_number_left
=
line
[
1
]
-
line_content_left
=
line
[
2
]
-
line_content_left
=
line
[
2
]
-
line_code
=
line
[
3
]
-
line_code
=
line
[
3
]
-
line_code_nex
t
=
line
[
4
]
-
type_righ
t
=
line
[
4
]
-
type
_right
=
line
[
5
]
-
line_number
_right
=
line
[
5
]
-
line_
number
_right
=
line
[
6
]
-
line_
content
_right
=
line
[
6
]
-
line_co
ntent
_right
=
line
[
7
]
-
line_co
de
_right
=
line
[
7
]
%tr
.line_holder.parallel
%tr
.line_holder.parallel
-
if
type_left
==
'match'
-
if
type_left
==
'match'
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
-
if
type_right
==
'new'
-
if
type_right
==
'new'
-
new_line_class
=
'new'
-
new_line_class
=
'new'
-
new_line_code
=
line_code_
nex
t
-
new_line_code
=
line_code_
righ
t
-
else
-
else
-
new_line_class
=
nil
-
new_line_class
=
nil
-
new_line_code
=
line_code
-
new_line_code
=
line_code
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
-
else
-
else
-
comments1
=
line_comments
[
line_code
]
-
comments1
=
line_comments
[
line_code
]
-
unless
type_left
.
nil?
&&
type_right
.
nil?
-
unless
type_left
.
nil?
&&
type_right
.
nil?
-
comments2
=
line_comments
[
line_code_
nex
t
]
-
comments2
=
line_comments
[
line_code_
righ
t
]
-
if
comments1
.
present?
||
comments2
.
present?
-
if
comments1
.
present?
||
comments2
.
present?
=
render
"projects/notes/diff_notes_with_reply_parallel"
,
notes1:
comments1
,
notes2:
comments2
=
render
"projects/notes/diff_notes_with_reply_parallel"
,
notes1:
comments1
,
notes2:
comments2
...
...
app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml
View file @
e84861d5
-
note1
=
notes1
.
present?
?
notes1
.
first
:
nil
-
note1
=
notes1
.
present?
?
notes1
.
first
:
nil
-
note2
=
notes2
.
present?
?
notes2
.
first
:
nil
-
note2
=
notes2
.
present?
?
notes2
.
first
:
nil
-# Check if line want not changed since comment was left
/- if !defined?(line) || line == note.diff_line
%tr
.notes_holder
%tr
.notes_holder
-
if
note1
-
if
note1
%td
.notes_line
%td
.notes_line
...
...
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