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
iv
gitlab-ce
Commits
c71892e1
Commit
c71892e1
authored
Nov 13, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Even more refactoring to inline_diff.rb
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
c903f23f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
16 deletions
+23
-16
lib/gitlab/inline_diff.rb
lib/gitlab/inline_diff.rb
+23
-16
No files found.
lib/gitlab/inline_diff.rb
View file @
c71892e1
...
@@ -17,6 +17,16 @@ module Gitlab
...
@@ -17,6 +17,16 @@ module Gitlab
next
if
first_line
==
"-
\n
"
next
if
first_line
==
"-
\n
"
first_token
=
find_first_token
(
first_line
,
second_line
)
first_token
=
find_first_token
(
first_line
,
second_line
)
apply_first_token
(
diff_arr
,
index
,
first_token
)
last_token
=
find_last_token
(
first_line
,
second_line
,
first_token
)
apply_last_token
(
diff_arr
,
index
,
last_token
)
end
diff_arr
end
def
apply_first_token
(
diff_arr
,
index
,
first_token
)
start
=
first_token
+
START
start
=
first_token
+
START
if
first_token
.
empty?
if
first_token
.
empty?
...
@@ -27,9 +37,9 @@ module Gitlab
...
@@ -27,9 +37,9 @@ module Gitlab
diff_arr
[
index
+
1
].
sub!
(
first_token
,
first_token
=>
start
)
diff_arr
[
index
+
1
].
sub!
(
first_token
,
first_token
=>
start
)
diff_arr
[
index
+
2
].
sub!
(
first_token
,
first_token
=>
start
)
diff_arr
[
index
+
2
].
sub!
(
first_token
,
first_token
=>
start
)
end
end
end
last_token
=
find_last_token
(
first_line
,
second_line
,
first_token
)
def
apply_last_token
(
diff_arr
,
index
,
last_token
)
# This is tricky: escape backslashes so that `sub` doesn't interpret them
# This is tricky: escape backslashes so that `sub` doesn't interpret them
# as backreferences. Regexp.escape does NOT do the right thing.
# as backreferences. Regexp.escape does NOT do the right thing.
replace_token
=
FINISH
+
last_token
.
gsub
(
/\\/
,
'\&\&'
)
replace_token
=
FINISH
+
last_token
.
gsub
(
/\\/
,
'\&\&'
)
...
@@ -37,9 +47,6 @@ module Gitlab
...
@@ -37,9 +47,6 @@ module Gitlab
diff_arr
[
index
+
2
].
sub!
(
/
#{
Regexp
.
escape
(
last_token
)
}
$/
,
replace_token
)
diff_arr
[
index
+
2
].
sub!
(
/
#{
Regexp
.
escape
(
last_token
)
}
$/
,
replace_token
)
end
end
diff_arr
end
def
find_first_token
(
first_line
,
second_line
)
def
find_first_token
(
first_line
,
second_line
)
max_length
=
[
first_line
.
size
,
second_line
.
size
].
max
max_length
=
[
first_line
.
size
,
second_line
.
size
].
max
first_the_same_symbols
=
0
first_the_same_symbols
=
0
...
...
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