georgi-git_store 0.2.4 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ require "#{File.dirname(__FILE__)}/../lib/git_store"
2
+ require "#{File.dirname(__FILE__)}/helper"
3
+ require 'pp'
4
+
5
+ describe GitStore::Tree do
6
+ REPO = '/tmp/git_store_test'
7
+
8
+ attr_reader :store, :tree
9
+
10
+ before(:each) do
11
+ FileUtils.rm_rf REPO
12
+ Dir.mkdir REPO
13
+ Dir.chdir REPO
14
+
15
+ `git init`
16
+
17
+ @store = GitStore.new(REPO)
18
+ end
19
+
20
+ it "should parse a table" do
21
+ tree = GitStore::Tree.new(store)
22
+
23
+ a = store.put_object("blob", "a")
24
+ b = store.put_object("blob", "b")
25
+ c = store.put_object("blob", "c")
26
+
27
+ data =
28
+ "100644 a\0#{ [a].pack("H*") }" +
29
+ "100644 b\0#{ [b].pack("H*") }" +
30
+ "100644 c\0#{ [c].pack("H*") }"
31
+
32
+ tree.parse(data)
33
+
34
+ tree.get('a').should == 'a'
35
+ tree.get('b').should == 'b'
36
+ tree.get('c').should == 'c'
37
+ end
38
+
39
+ it "should write a table" do
40
+ tree = GitStore::Tree.new(store)
41
+
42
+ tree['a'] = 'a'
43
+ tree['b'] = 'b'
44
+ tree['c'] = 'c'
45
+
46
+ id = tree.write
47
+
48
+ a = ["2e65efe2a145dda7ee51d1741299f848e5bf752e"].pack('H*')
49
+ b = ["63d8dbd40c23542e740659a7168a0ce3138ea748"].pack('H*')
50
+ c = ["3410062ba67c5ed59b854387a8bc0ec012479368"].pack('H*')
51
+
52
+ data =
53
+ "100644 a\0#{a}" +
54
+ "100644 b\0#{b}" +
55
+ "100644 c\0#{c}"
56
+
57
+ store.get_object(id).should == ['tree', data]
58
+ end
59
+
60
+ it "should save trees" do
61
+ tree = GitStore::Tree.new(store)
62
+
63
+ tree['a'] = 'a'
64
+ tree['b'] = 'b'
65
+ tree['c'] = 'c'
66
+
67
+ tree.write
68
+
69
+ git_ls_tree(tree.id).should ==
70
+ [["100644", "blob", "2e65efe2a145dda7ee51d1741299f848e5bf752e", "a"],
71
+ ["100644", "blob", "63d8dbd40c23542e740659a7168a0ce3138ea748", "b"],
72
+ ["100644", "blob", "3410062ba67c5ed59b854387a8bc0ec012479368", "c"]]
73
+ end
74
+
75
+ it "should save nested trees" do
76
+ tree = GitStore::Tree.new(store)
77
+
78
+ tree['x/a'] = 'a'
79
+ tree['x/b'] = 'b'
80
+ tree['x/c'] = 'c'
81
+
82
+ tree.write
83
+
84
+ git_ls_tree(tree.id) ==
85
+ [["040000", "tree", "24e88cb96c396400000ef706d1ca1ed9a88251aa", "x"]]
86
+
87
+ git_ls_tree("24e88cb96c396400000ef706d1ca1ed9a88251aa").should ==
88
+ [["100644", "blob", "2e65efe2a145dda7ee51d1741299f848e5bf752e", "a"],
89
+ ["100644", "blob", "63d8dbd40c23542e740659a7168a0ce3138ea748", "b"],
90
+ ["100644", "blob", "3410062ba67c5ed59b854387a8bc0ec012479368", "c"]]
91
+ end
92
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: georgi-git_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Georgi
@@ -29,9 +29,13 @@ files:
29
29
  - git_store.gemspec
30
30
  - lib/git_store.rb
31
31
  - lib/git_store/blob.rb
32
+ - lib/git_store/commit.rb
33
+ - lib/git_store/diff.rb
32
34
  - lib/git_store/tree.rb
33
35
  - lib/git_store/handlers.rb
34
36
  - lib/git_store/pack.rb
37
+ - test/tree_spec.rb
38
+ - test/commit_spec.rb
35
39
  - test/git_store_spec.rb
36
40
  - test/benchmark.rb
37
41
  has_rdoc: true