Skip to content
Snippets Groups Projects
Commit ea55707b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Improve commit diff

* show highlights when replace empty line with content
* show inline diff when replace line with spaces with content
parent 8b3ada75
No related branches found
No related tags found
1 merge request!4948CentOS 6.4 install GitLab 6 0 stable ssh Auth fail
This commit is part of merge request !4948. Comments created here will be created in the context of that merge request.
Loading
@@ -13,6 +13,9 @@ module Gitlab
Loading
@@ -13,6 +13,9 @@ module Gitlab
second_line = diff_arr[index+2] second_line = diff_arr[index+2]
max_length = [first_line.size, second_line.size].max max_length = [first_line.size, second_line.size].max
   
# Skip inline diff if empty line was replaced with content
next if first_line == "-\n"
first_the_same_symbols = 0 first_the_same_symbols = 0
(0..max_length + 1).each do |i| (0..max_length + 1).each do |i|
first_the_same_symbols = i - 1 first_the_same_symbols = i - 1
Loading
@@ -20,10 +23,19 @@ module Gitlab
Loading
@@ -20,10 +23,19 @@ module Gitlab
break break
end end
end end
first_token = first_line[0..first_the_same_symbols][1..-1] first_token = first_line[0..first_the_same_symbols][1..-1]
start = first_token + START start = first_token + START
diff_arr[index+1].sub!(first_token, first_token => start)
diff_arr[index+2].sub!(first_token, first_token => start) if first_token.empty?
# In case if we remove string of spaces in commit
diff_arr[index+1].sub!("-", "-" => "-#{START}")
diff_arr[index+2].sub!("+", "+" => "+#{START}")
else
diff_arr[index+1].sub!(first_token, first_token => start)
diff_arr[index+2].sub!(first_token, first_token => start)
end
last_the_same_symbols = 0 last_the_same_symbols = 0
(1..max_length + 1).each do |i| (1..max_length + 1).each do |i|
last_the_same_symbols = -i last_the_same_symbols = -i
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment