Commit a6cf8ea6725ace47106ca8f10ce233252b0fd95c

updated Diff::Display library

Commit diff

vendor/diff-display/lib/diff/display/unified/generator.rb

 
1111 class Unified::Generator
1212
1313 # Extracts the line number info for a given diff section
14 LINE_NUM_RE = /@@ [+-]([0-9]+)(?:,([0-9]+))? [+-]([0-9]+)(?:,([0-9]+))? @@/
14 LINE_NUM_RE = /^@@ [+-]([0-9]+)(?:,([0-9]+))? [+-]([0-9]+)(?:,([0-9]+))? @@/
1515 LINE_TYPES = {'+' => :add, '-' => :rem, ' ' => :unmod}
1616
1717 # Runs the generator on a diff and returns a Data object
8888
8989 protected
9090 def is_header_line?(line)
91 return true if ['++', '--'].include?(line[0,2])
91 return true if ['+++ ', '--- '].include?(line[0,4])
9292 return true if line =~ /^(new|delete) file mode [0-9]+$/
9393 return true if line =~ /^diff \-\-git/
9494 return true if line =~ /^index \w+\.\.\w+ [0-9]+$/
toggle raw diff

vendor/diff-display/spec/fixtures/pseudo_recursive.diff

 
1diff --git a/spec/fixtures/multiple_rems_then_add.diff b/spec/fixtures/multiple_rems_then_add.diff
2new file mode 100644
3index 0000000..f5fd3f8
4--- /dev/null
5+++ b/spec/fixtures/multiple_rems_then_add.diff
6@@ -0,0 +1,14 @@
7+diff --git a/strokedb-ruby/lib/stores/chainable_storage.rb b/strokedb-ruby/lib/stores/chainable_storage.rb
8+index 5326c92..1e2de8f 100644
9+--- a/strokedb-ruby/lib/stores/chainable_storage.rb
10++++ b/strokedb-ruby/lib/stores/chainable_storage.rb
11+@@ -44,9 +44,7 @@ module StrokeDB
12+ def save_with_chained_storages!(chunk,source=nil)
13+ perform_save!(chunk)
14+ (@chained_storages||{}).each_pair do |storage,savings|
15+- unless storage == chunk
16+- savings << chunk unless savings.include?(chunk)
17+- end
18diff --git a/spec/fixtures/multiple_rems_then_add.diff b/spec/fixtures/multiple_rems_then_add.diff
19new file mode 100644
20index 0000000..f5fd3f8
21--- /dev/null
22+++ b/spec/fixtures/multiple_rems_then_add.diff
23@@ -0,0 +1,14 @@
24+diff --git a/strokedb-ruby/lib/stores/chainable_storage.rb b/strokedb-ruby/lib/stores/chainable_storage.rb
25+index 5326c92..1e2de8f 100644
26+--- a/strokedb-ruby/lib/stores/chainable_storage.rb
27++++ b/strokedb-ruby/lib/stores/chainable_storage.rb
28+@@ -44,9 +44,7 @@ module StrokeDB
29+ def save_with_chained_storages!(chunk,source=nil)
30+ perform_save!(chunk)
31+ (@chained_storages||{}).each_pair do |storage,savings|
32+- unless storage == chunk
33+- savings << chunk unless savings.include?(chunk)
34+- end
35+ end
36+ end
37\ No newline at end of file
toggle raw diff

vendor/diff-display/spec/generator_spec.rb

 
3636 it "multiple rems and an add is in parity" do
3737 diff_data = load_diff("multiple_rems_then_add")
3838 data = Diff::Display::Unified::Generator.run(diff_data)
39 #pp data
4039 data.to_diff.should == diff_data.chomp
4140 end
4241
42 it "doesn't parse linenumbers that isn't part if the diff" do
43 diff_data = load_diff("pseudo_recursive")
44 data = Diff::Display::Unified::Generator.run(diff_data)
45 linenos = []
46 data.each{|blk| blk.each{|line| linenos << line.number } }
47 linenos.compact.should == (1..14).to_a
48 end
49
4350 end
4451
4552end
toggle raw diff