html-diff 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/html_diff.rb +6 -0
- metadata +1 -1
data/lib/html_diff.rb
CHANGED
@@ -8,6 +8,9 @@ class HtmlDiff
|
|
8
8
|
|
9
9
|
def stats_line
|
10
10
|
stats=`git diff --stat #{@argv.join(" ")}`
|
11
|
+
if stats.blank?
|
12
|
+
return "no changes"
|
13
|
+
end
|
11
14
|
stats.scan(/\d+ files? changed, \d+ insertions?\(\+\), \d+ deletions?\(\-\)/).last
|
12
15
|
end
|
13
16
|
|
@@ -18,6 +21,9 @@ class HtmlDiff
|
|
18
21
|
|
19
22
|
def html_diff
|
20
23
|
diff=`git diff #{@argv.join(" ")}`
|
24
|
+
if diff.blank?
|
25
|
+
return
|
26
|
+
end
|
21
27
|
diff.gsub!(/^diff \-\-git a\/([^\s]*).*\n.*$/) { "<div class='diff-file'>"+$1+"</div>" }
|
22
28
|
diff.gsub!(/^(\-\-\-\s)(a.*)$/) { "<div class='code'><span class='delete'>"+$1+" "+$2+"</span>" }
|
23
29
|
diff.gsub!(/(\n\<div class\=\'diff-file\'\>)/) { "</div>"+$1}
|