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
Tatuya Kamada
gitlab-ce
Commits
20a5033d
Commit
20a5033d
authored
Jul 19, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix method visibility in inline diff class
parent
e15b63b3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
35 deletions
+39
-35
lib/gitlab/diff/inline_diff.rb
lib/gitlab/diff/inline_diff.rb
+39
-35
No files found.
lib/gitlab/diff/inline_diff.rb
View file @
20a5033d
...
@@ -19,24 +19,6 @@ module Gitlab
...
@@ -19,24 +19,6 @@ module Gitlab
attr_accessor
:old_line
,
:new_line
,
:offset
attr_accessor
:old_line
,
:new_line
,
:offset
def
self
.
for_lines
(
lines
)
changed_line_pairs
=
self
.
find_changed_line_pairs
(
lines
)
inline_diffs
=
[]
changed_line_pairs
.
each
do
|
old_index
,
new_index
|
old_line
=
lines
[
old_index
]
new_line
=
lines
[
new_index
]
old_diffs
,
new_diffs
=
new
(
old_line
,
new_line
,
offset:
1
).
inline_diffs
inline_diffs
[
old_index
]
=
old_diffs
inline_diffs
[
new_index
]
=
new_diffs
end
inline_diffs
end
def
initialize
(
old_line
,
new_line
,
offset:
0
)
def
initialize
(
old_line
,
new_line
,
offset:
0
)
@old_line
=
old_line
[
offset
..-
1
]
@old_line
=
old_line
[
offset
..-
1
]
@new_line
=
new_line
[
offset
..-
1
]
@new_line
=
new_line
[
offset
..-
1
]
...
@@ -63,10 +45,29 @@ module Gitlab
...
@@ -63,10 +45,29 @@ module Gitlab
[
old_diffs
,
new_diffs
]
[
old_diffs
,
new_diffs
]
end
end
class
<<
self
def
for_lines
(
lines
)
changed_line_pairs
=
find_changed_line_pairs
(
lines
)
inline_diffs
=
[]
changed_line_pairs
.
each
do
|
old_index
,
new_index
|
old_line
=
lines
[
old_index
]
new_line
=
lines
[
new_index
]
old_diffs
,
new_diffs
=
new
(
old_line
,
new_line
,
offset:
1
).
inline_diffs
inline_diffs
[
old_index
]
=
old_diffs
inline_diffs
[
new_index
]
=
new_diffs
end
inline_diffs
end
private
private
# Finds pairs of old/new line pairs that represent the same line that changed
# Finds pairs of old/new line pairs that represent the same line that changed
def
self
.
find_changed_line_pairs
(
lines
)
def
find_changed_line_pairs
(
lines
)
# Prefixes of all diff lines, indicating their types
# Prefixes of all diff lines, indicating their types
# For example: `" - + -+ ---+++ --+ -++"`
# For example: `" - + -+ ---+++ --+ -++"`
line_prefixes
=
lines
.
each_with_object
(
""
)
{
|
line
,
s
|
s
<<
line
[
0
]
}.
gsub
(
/[^ +-]/
,
' '
)
line_prefixes
=
lines
.
each_with_object
(
""
)
{
|
line
,
s
|
s
<<
line
[
0
]
}.
gsub
(
/[^ +-]/
,
' '
)
...
@@ -88,6 +89,9 @@ module Gitlab
...
@@ -88,6 +89,9 @@ module Gitlab
changed_line_pairs
changed_line_pairs
end
end
end
private
def
longest_common_prefix
(
a
,
b
)
def
longest_common_prefix
(
a
,
b
)
max_length
=
[
a
.
length
,
b
.
length
].
max
max_length
=
[
a
.
length
,
b
.
length
].
max
...
...
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