rugged 0.0.1

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.
Files changed (59) hide show
  1. data/LICENSE +21 -0
  2. data/README.md +290 -0
  3. data/Rakefile +118 -0
  4. data/ext/rugged/extconf.rb +9 -0
  5. data/lib/rugged/index.rb +13 -0
  6. data/lib/rugged/ribbit.bundle +0 -0
  7. data/lib/rugged/rugged.bundle +0 -0
  8. data/lib/rugged/tree.rb +13 -0
  9. data/lib/rugged/tree_entry.rb +9 -0
  10. data/lib/rugged/version.rb +3 -0
  11. data/lib/rugged.rb +5 -0
  12. data/test/commit_test.rb +36 -0
  13. data/test/fixtures/testrepo.git/HEAD +1 -0
  14. data/test/fixtures/testrepo.git/config +6 -0
  15. data/test/fixtures/testrepo.git/description +1 -0
  16. data/test/fixtures/testrepo.git/index +0 -0
  17. data/test/fixtures/testrepo.git/info/exclude +6 -0
  18. data/test/fixtures/testrepo.git/logs/HEAD +3 -0
  19. data/test/fixtures/testrepo.git/logs/refs/heads/master +3 -0
  20. data/test/fixtures/testrepo.git/objects/0c/37a5391bbff43c37f0d0371823a5509eed5b1d +0 -0
  21. data/test/fixtures/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 +0 -0
  22. data/test/fixtures/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 +0 -0
  23. data/test/fixtures/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd +0 -0
  24. data/test/fixtures/testrepo.git/objects/2d/2eff63372b08adf0a9eb84109ccf7d19e2f3a2 +0 -0
  25. data/test/fixtures/testrepo.git/objects/36/060c58702ed4c2a40832c51758d5344201d89a +2 -0
  26. data/test/fixtures/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 +0 -0
  27. data/test/fixtures/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 +2 -0
  28. data/test/fixtures/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 +2 -0
  29. data/test/fixtures/testrepo.git/objects/61/9f9935957e010c419cb9d15621916ddfcc0b96 +0 -0
  30. data/test/fixtures/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a +0 -0
  31. data/test/fixtures/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d +0 -0
  32. data/test/fixtures/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 +0 -0
  33. data/test/fixtures/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a +3 -0
  34. data/test/fixtures/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f +2 -0
  35. data/test/fixtures/testrepo.git/objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd +0 -0
  36. data/test/fixtures/testrepo.git/objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6 +0 -0
  37. data/test/fixtures/testrepo.git/objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644 +3 -0
  38. data/test/fixtures/testrepo.git/objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd +3 -0
  39. data/test/fixtures/testrepo.git/objects/c4/dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b +0 -0
  40. data/test/fixtures/testrepo.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  41. data/test/fixtures/testrepo.git/objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1 +0 -0
  42. data/test/fixtures/testrepo.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92 +0 -0
  43. data/test/fixtures/testrepo.git/objects/fd/093bff70906175335656e6ce6ae05783708765 +0 -0
  44. data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx +0 -0
  45. data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack +0 -0
  46. data/test/fixtures/testrepo.git/packed-refs +2 -0
  47. data/test/fixtures/testrepo.git/refs/heads/master +1 -0
  48. data/test/fixtures/testrepo.git/refs/tags/v0.9 +1 -0
  49. data/test/fixtures/testrepo.git/refs/tags/v1.0 +1 -0
  50. data/test/index_test.rb +161 -0
  51. data/test/lib_test.rb +33 -0
  52. data/test/object_test.rb +33 -0
  53. data/test/repo_pack_test.rb +22 -0
  54. data/test/repo_test.rb +45 -0
  55. data/test/tag_test.rb +34 -0
  56. data/test/test_helper.rb +35 -0
  57. data/test/tree_test.rb +40 -0
  58. data/test/walker_test.rb +79 -0
  59. metadata +128 -0
@@ -0,0 +1,161 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'base64'
3
+ require 'tempfile'
4
+ require 'fileutils'
5
+
6
+ def new_index_entry
7
+ now = Time.now
8
+ e = Rugged::IndexEntry.new
9
+ e.path = "new_path"
10
+ e.sha = "d385f264afb75a56a5bec74243be9b367ba4ca08"
11
+ e.mtime = now
12
+ e.ctime = now
13
+ e.file_size = 1000
14
+ e.dev = 234881027
15
+ e.ino = 88888
16
+ e.mode = 33199
17
+ e.uid = 502
18
+ e.gid = 502
19
+ e.flags = 5
20
+ e.flags_extended = 5
21
+ e
22
+ end
23
+
24
+ context "Rugged::Index reading stuff" do
25
+ setup do
26
+ path = File.dirname(__FILE__) + '/fixtures/testrepo.git/index'
27
+ @index = Rugged::Index.new(path)
28
+ @index.refresh
29
+ end
30
+
31
+ test "can count index entries" do
32
+ assert_equal 2, @index.entry_count
33
+ end
34
+
35
+ test "can clear the in-memory index" do
36
+ @index.clear
37
+ assert_equal 0, @index.entry_count
38
+ end
39
+
40
+ test "can get all data from an entry" do
41
+ e = @index.get_entry(0)
42
+ assert_equal 'README', e.path
43
+ assert_equal '1385f264afb75a56a5bec74243be9b367ba4ca08', e.sha
44
+ assert_equal 1273360380, e.mtime.to_i
45
+ assert_equal 1273360380, e.ctime.to_i
46
+ assert_equal 4, e.file_size
47
+ assert_equal 234881026, e.dev
48
+ assert_equal 6674088, e.ino
49
+ assert_equal 33188, e.mode
50
+ assert_equal 501, e.uid
51
+ assert_equal 0, e.gid
52
+ assert_equal 6, e.flags
53
+ assert_equal 0, e.flags_extended
54
+
55
+ e = @index.get_entry(1)
56
+ assert_equal 'new.txt', e.path
57
+ assert_equal 'fa49b077972391ad58037050f2a75f74e3671e92', e.sha
58
+ end
59
+
60
+ test "can iterate over the entries" do
61
+ itr_test = @index.sort { |a, b| a.sha <=> b.sha }.map { |e| e.path }.join(':')
62
+ assert_equal "README:new.txt", itr_test
63
+ end
64
+
65
+ test "can update entries" do
66
+ now = Time.now
67
+ e = @index.get_entry(0)
68
+
69
+ e.path = "new_path"
70
+ e.sha = "12ea3153a78002a988bb92f4123e7e831fd1138a"
71
+ e.mtime = now
72
+ e.ctime = now
73
+ e.file_size = 1000
74
+ e.dev = 234881027
75
+ e.ino = 88888
76
+ e.mode = 33199
77
+ e.uid = 502
78
+ e.gid = 502
79
+ e.flags = 5
80
+ e.flags_extended = 5
81
+
82
+ assert_equal 'new_path', e.path
83
+ assert_equal '12ea3153a78002a988bb92f4123e7e831fd1138a', e.sha
84
+ assert_equal now, e.mtime
85
+ assert_equal now, e.ctime
86
+ assert_equal 1000, e.file_size
87
+ assert_equal 234881027, e.dev
88
+ assert_equal 88888, e.ino
89
+ assert_equal 33199, e.mode
90
+ assert_equal 502, e.uid
91
+ assert_equal 502, e.gid
92
+ assert_equal 5, e.flags
93
+ assert_equal 5, e.flags_extended
94
+ end
95
+
96
+ test "can add new entries" do
97
+ e = new_index_entry
98
+ @index.add(e)
99
+ assert_equal 3, @index.entry_count
100
+ itr_test = @index.sort { |a, b| a.sha <=> b.sha }.map { |e| e.path }.join(':')
101
+ assert_equal "README:new_path:new.txt", itr_test
102
+ end
103
+
104
+
105
+ end
106
+
107
+ context "Rugged::Index writing stuff" do
108
+ setup do
109
+ path = File.dirname(__FILE__) + '/fixtures/testrepo.git/index'
110
+ @tmppath = Tempfile.new('index').path
111
+ FileUtils.copy(path, @tmppath)
112
+ @index = Rugged::Index.new(@tmppath)
113
+ @index.refresh
114
+ end
115
+
116
+ test "add raises if it gets something weird" do
117
+ assert_raise TypeError do
118
+ @index.add(21)
119
+ end
120
+ end
121
+
122
+ test "can write a new index" do
123
+ e = new_index_entry
124
+ @index.add(e)
125
+ e.path = "else.txt"
126
+ @index.add(e)
127
+ @index.write
128
+
129
+ index2 = Rugged::Index.new(@tmppath)
130
+ index2.refresh
131
+
132
+ itr_test = index2.sort { |a, b| a.sha <=> b.sha }.map { |e| e.path }.join(':')
133
+ assert_equal "README:else.txt:new_path:new.txt", itr_test
134
+ assert_equal 4, index2.entry_count
135
+ end
136
+ end
137
+
138
+ context "Rugged::Index with working directory" do
139
+ setup do
140
+ @tmppath = Tempfile.new('index').path + '_dir'
141
+ FileUtils.mkdir(@tmppath)
142
+ Dir.chdir(@tmppath) do
143
+ `git init`
144
+ end
145
+ @repo = Rugged::Repository.new(@tmppath + '/.git')
146
+ @index = @repo.index
147
+ end
148
+
149
+ test "can add from a path" do
150
+ File.open(File.join(@tmppath, 'test.txt'), 'w') do |f|
151
+ f.puts "test content"
152
+ end
153
+ @index.add('test.txt')
154
+ @index.write
155
+
156
+ index2 = Rugged::Index.new(@tmppath + '/.git/index')
157
+ index2.refresh
158
+
159
+ assert_equal index2.get_entry(0).path, 'test.txt'
160
+ end
161
+ end
data/test/lib_test.rb ADDED
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'base64'
3
+
4
+ context "Rugged::Lib stuff" do
5
+ setup do
6
+ end
7
+
8
+ test "can convert hex into raw sha" do
9
+ raw = Rugged::Lib.hex_to_raw("ce08fe4884650f067bd5703b6a59a8b3b3c99a09")
10
+ b64raw = Base64.encode64(raw).strip
11
+ assert_equal "zgj+SIRlDwZ71XA7almos7PJmgk=", b64raw
12
+ end
13
+
14
+ test "converts hex into raw sha correctly" do
15
+ hex = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09"
16
+ raw1 = Rugged::Lib.hex_to_raw(hex)
17
+ raw2 = [hex].pack("H*")
18
+ assert_equal raw1, raw2
19
+ end
20
+
21
+ test "can convert raw sha into hex" do
22
+ raw = Base64.decode64("FqASNFZ4mrze9Ld1ITwjqL109eA=")
23
+ hex = Rugged::Lib.raw_to_hex(raw)
24
+ assert_equal "16a0123456789abcdef4b775213c23a8bd74f5e0", hex
25
+ end
26
+
27
+ test "converts raw into hex sha correctly" do
28
+ raw = Rugged::Lib.hex_to_raw("ce08fe4884650f067bd5703b6a59a8b3b3c99a09")
29
+ hex1 = Rugged::Lib.raw_to_hex(raw)
30
+ hex2 = raw.unpack("H*")[0]
31
+ assert_equal hex1, hex2
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'base64'
3
+
4
+ context "Rugged::Object stuff" do
5
+ setup do
6
+ @path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
7
+ @repo = Rugged::Repository.new(@path)
8
+ end
9
+
10
+ test "cannot lookup a non-existant object" do
11
+ assert_raise RuntimeError do
12
+ obj = @repo.lookup("a496071c1b46c854b31185ea97743be6a8774479")
13
+ end
14
+ end
15
+
16
+ test "can lookup an object" do
17
+ obj = @repo.lookup("8496071c1b46c854b31185ea97743be6a8774479")
18
+ assert_equal 'commit', obj.type
19
+ assert_equal '8496071c1b46c854b31185ea97743be6a8774479', obj.sha
20
+ end
21
+
22
+ test "same looked up objects are the same" do
23
+ obj = @repo.lookup("8496071c1b46c854b31185ea97743be6a8774479")
24
+ obj2 = @repo.lookup("8496071c1b46c854b31185ea97743be6a8774479")
25
+ assert_equal obj, obj2
26
+ end
27
+
28
+ test "can read raw data from an object" do
29
+ obj = @repo.lookup("8496071c1b46c854b31185ea97743be6a8774479")
30
+ assert obj.read_raw
31
+ end
32
+
33
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'base64'
3
+
4
+ context "Rugged::Repository packed stuff" do
5
+ setup do
6
+ path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
7
+ @repo = Rugged::Repository.new(path)
8
+ end
9
+
10
+ test "can tell if a packed object exists" do
11
+ assert @repo.exists("41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9")
12
+ assert @repo.exists("f82a8eb4cb20e88d1030fd10d89286215a715396")
13
+ end
14
+
15
+ test "can read a packed object from the db" do
16
+ data, len, type = @repo.read("41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9")
17
+ assert_match 'tree f82a8eb4cb20e88d1030fd10d89286215a715396', data
18
+ assert_equal 230, len
19
+ assert_equal "commit", type
20
+ end
21
+
22
+ end
data/test/repo_test.rb ADDED
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'base64'
3
+
4
+ context "Rugged::Repository stuff" do
5
+ setup do
6
+ @path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
7
+ @repo = Rugged::Repository.new(@path)
8
+ end
9
+
10
+ test "can tell if an object exists or not" do
11
+ assert @repo.exists("8496071c1b46c854b31185ea97743be6a8774479")
12
+ assert @repo.exists("1385f264afb75a56a5bec74243be9b367ba4ca08")
13
+ assert !@repo.exists("ce08fe4884650f067bd5703b6a59a8b3b3c99a09")
14
+ assert !@repo.exists("8496071c1c46c854b31185ea97743be6a8774479")
15
+ end
16
+
17
+ test "can read an object from the db" do
18
+ data, len, type = @repo.read("8496071c1b46c854b31185ea97743be6a8774479")
19
+ assert_match 'tree 181037049a54a1eb5fab404658a3a250b44335d7', data
20
+ assert_equal 172, len
21
+ assert_equal "commit", type
22
+ end
23
+
24
+ test "checks that reading fails on unexistang objects" do
25
+ assert_raise RuntimeError do
26
+ @repo.read("a496071c1b46c854b31185ea97743be6a8774471")
27
+ end
28
+ end
29
+
30
+ test "can hash data" do
31
+ content = "my test data\n"
32
+ sha = @repo.hash(content, "blob")
33
+ assert_equal "76b1b55ab653581d6f2c7230d34098e837197674", sha
34
+ assert !@repo.exists("76b1b55ab653581d6f2c7230d34098e837197674")
35
+ end
36
+
37
+ test "can write to the db" do
38
+ content = "my test data\n"
39
+ sha = @repo.write(content, "blob")
40
+ assert_equal "76b1b55ab653581d6f2c7230d34098e837197674", sha
41
+ assert @repo.exists("76b1b55ab653581d6f2c7230d34098e837197674")
42
+ rm_loose("76b1b55ab653581d6f2c7230d34098e837197674")
43
+ end
44
+
45
+ end
data/test/tag_test.rb ADDED
@@ -0,0 +1,34 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ context "Rugged::Tag tests" do
4
+ setup do
5
+ @path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
6
+ @repo = Rugged::Repository.new(@path)
7
+ end
8
+
9
+ test "can read the tag data" do
10
+ sha = "0c37a5391bbff43c37f0d0371823a5509eed5b1d"
11
+ obj = @repo.lookup(sha)
12
+
13
+ assert_equal sha, obj.sha
14
+ assert_equal "tag", obj.type
15
+ assert_equal "test tag message\n", obj.message
16
+ assert_equal "v1.0", obj.name
17
+ assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644", obj.target.sha
18
+ assert_equal "commit", obj.target_type
19
+ c = obj.tagger
20
+ assert_equal "Scott Chacon", c['name']
21
+ assert_equal 1288114383, c['time'].to_i
22
+ assert_equal "schacon@gmail.com", c['email']
23
+ end
24
+
25
+ test "can write the tag data" do
26
+ sha = "0c37a5391bbff43c37f0d0371823a5509eed5b1d"
27
+ obj = @repo.lookup(sha)
28
+ obj.message = 'new messages'
29
+ obj.write
30
+ assert_equal "3213a37f636b81c3f91c77c6dbeab47c1d38490a", obj.sha
31
+ rm_loose('3213a37f636b81c3f91c77c6dbeab47c1d38490a')
32
+ end
33
+
34
+ end
@@ -0,0 +1,35 @@
1
+ dir = File.dirname(File.expand_path(__FILE__))
2
+ $LOAD_PATH.unshift dir + '/../lib'
3
+ $TESTING = true
4
+ require 'test/unit'
5
+ require 'rubygems'
6
+ require 'rugged'
7
+ require 'pp'
8
+
9
+ ##
10
+ # test/spec/mini 3
11
+ # http://gist.github.com/25455
12
+ # chris@ozmm.org
13
+ #
14
+ def context(*args, &block)
15
+ return super unless (name = args.first) && block
16
+ require 'test/unit'
17
+ klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
18
+ def self.test(name, &block)
19
+ define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
20
+ end
21
+ def self.xtest(*args) end
22
+ def self.setup(&block) define_method(:setup, &block) end
23
+ def self.teardown(&block) define_method(:teardown, &block) end
24
+ end
25
+ (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
26
+ klass.class_eval &block
27
+ end
28
+
29
+ def rm_loose(sha)
30
+ dir = sha[0, 2]
31
+ rest = sha[2, 38]
32
+ file = File.join(@path, "objects", dir, rest)
33
+ `rm -f #{file}`
34
+ end
35
+
data/test/tree_test.rb ADDED
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ context "Rugged::Tree tests" do
4
+ setup do
5
+ path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
6
+ @repo = Rugged::Repository.new(path)
7
+ @sha = "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"
8
+ @tree = @repo.lookup(@sha)
9
+ end
10
+
11
+ test "can read the tree data" do
12
+ assert_equal @sha, @tree.sha
13
+ assert_equal "tree", @tree.type
14
+ assert_equal 3, @tree.entry_count
15
+ assert_equal "1385f264afb75a56a5bec74243be9b367ba4ca08", @tree[0].sha
16
+ assert_equal "fa49b077972391ad58037050f2a75f74e3671e92", @tree[1].sha
17
+ end
18
+
19
+ test "can read the tree entry data" do
20
+ bent = @tree[0]
21
+ tent = @tree[2]
22
+
23
+ assert_equal "README", bent.name
24
+ assert_equal bent.to_object.sha, bent.sha
25
+ # assert_equal 33188, bent.attributes
26
+
27
+ assert_equal "subdir", tent.name
28
+ assert_equal "619f9935957e010c419cb9d15621916ddfcc0b96", tent.to_object.sha
29
+ assert_equal "tree", tent.to_object.type
30
+ end
31
+
32
+ test "can iterate over the tree" do
33
+ enum_test = @tree.sort { |a, b| a.sha <=> b.sha }.map { |e| e.name }.join(':')
34
+ assert_equal "README:subdir:new.txt", enum_test
35
+ end
36
+
37
+ xtest "can write the tree data" do
38
+ end
39
+
40
+ end
@@ -0,0 +1,79 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'base64'
3
+
4
+ context "Rugged::Walker stuff" do
5
+ setup do
6
+ @path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
7
+ @repo = Rugged::Repository.new(@path)
8
+ @walker = Rugged::Walker.new(@repo)
9
+ end
10
+
11
+ test "can walk a simple revlist" do
12
+ @walker.push("9fd738e8f7967c078dceed8190330fc8648ee56a")
13
+ data = []
14
+ 4.times do
15
+ data << @walker.next.sha
16
+ end
17
+ shas = data.sort.map {|a| a[0,5]}.join('.')
18
+ assert_equal "4a202.5b5b0.84960.9fd73", shas
19
+ assert_equal false, @walker.next
20
+ end
21
+
22
+ test "can walk a part of a revlist" do
23
+ sha = "8496071c1b46c854b31185ea97743be6a8774479"
24
+ @walker.push(sha)
25
+ assert_equal sha, @walker.next.sha
26
+ assert_equal false, @walker.next
27
+ end
28
+
29
+ test "can hide part of a list" do
30
+ @walker.push("9fd738e8f7967c078dceed8190330fc8648ee56a")
31
+ @walker.hide("5b5b025afb0b4c913b4c338a42934a3863bf3644")
32
+ 2.times { @walker.next }
33
+ assert_equal false, @walker.next
34
+ end
35
+
36
+ # resetting a walker emtpies the walking queue
37
+ test "can reset a walker" do
38
+ sha = "8496071c1b46c854b31185ea97743be6a8774479"
39
+ @walker.push(sha)
40
+ assert_equal sha, @walker.next.sha
41
+ assert_equal false, @walker.next
42
+ @walker.reset
43
+ assert_equal false, @walker.next
44
+ @walker.push(sha)
45
+ assert_equal sha, @walker.next.sha
46
+ end
47
+
48
+ def revlist_with_sorting(sorting)
49
+ sha = "a4a7dce85cf63874e984719f4fdd239f5145052f"
50
+ @walker.sorting(sorting)
51
+ @walker.push(sha)
52
+ data = []
53
+ 6.times do
54
+ data << @walker.next
55
+ end
56
+ shas = data.map {|a| a.sha[0,5] if a }.join('.')
57
+ end
58
+
59
+ test "can sort order by date" do
60
+ time = revlist_with_sorting(Rugged::SORT_DATE)
61
+ assert_equal "a4a7d.c4780.9fd73.4a202.5b5b0.84960", time
62
+ end
63
+
64
+ test "can sort order by topo" do
65
+ topo = revlist_with_sorting(Rugged::SORT_TOPO)
66
+ assert_equal "a4a7d.c4780.9fd73.4a202.5b5b0.84960", topo
67
+ end
68
+
69
+ test "can sort order by date reversed" do
70
+ time = revlist_with_sorting(Rugged::SORT_DATE | Rugged::SORT_REVERSE)
71
+ assert_equal "84960.5b5b0.4a202.9fd73.c4780.a4a7d", time
72
+ end
73
+
74
+ test "can sort order by topo reversed" do
75
+ topo_rev = revlist_with_sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
76
+ assert_equal "84960.5b5b0.4a202.9fd73.c4780.a4a7d", topo_rev
77
+ end
78
+
79
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rugged
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Scott Chacon
14
+ - Vicent Marti
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-11-17 00:00:00 -08:00
20
+ default_executable:
21
+ dependencies: []
22
+
23
+ description: |
24
+ Rugged is a Ruby bindings to the libgit2 linkable C Git library. This is
25
+ for testing and using the libgit2 library in a language that is awesome.
26
+
27
+ email: schacon@gmail.com
28
+ executables: []
29
+
30
+ extensions:
31
+ - ext/rugged/extconf.rb
32
+ extra_rdoc_files: []
33
+
34
+ files:
35
+ - README.md
36
+ - Rakefile
37
+ - LICENSE
38
+ - lib/rugged/index.rb
39
+ - lib/rugged/ribbit.bundle
40
+ - lib/rugged/rugged.bundle
41
+ - lib/rugged/tree.rb
42
+ - lib/rugged/tree_entry.rb
43
+ - lib/rugged/version.rb
44
+ - lib/rugged.rb
45
+ - test/commit_test.rb
46
+ - test/fixtures/testrepo.git/config
47
+ - test/fixtures/testrepo.git/description
48
+ - test/fixtures/testrepo.git/HEAD
49
+ - test/fixtures/testrepo.git/index
50
+ - test/fixtures/testrepo.git/info/exclude
51
+ - test/fixtures/testrepo.git/logs/HEAD
52
+ - test/fixtures/testrepo.git/logs/refs/heads/master
53
+ - test/fixtures/testrepo.git/objects/0c/37a5391bbff43c37f0d0371823a5509eed5b1d
54
+ - test/fixtures/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08
55
+ - test/fixtures/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7
56
+ - test/fixtures/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd
57
+ - test/fixtures/testrepo.git/objects/2d/2eff63372b08adf0a9eb84109ccf7d19e2f3a2
58
+ - test/fixtures/testrepo.git/objects/36/060c58702ed4c2a40832c51758d5344201d89a
59
+ - test/fixtures/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057
60
+ - test/fixtures/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045
61
+ - test/fixtures/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644
62
+ - test/fixtures/testrepo.git/objects/61/9f9935957e010c419cb9d15621916ddfcc0b96
63
+ - test/fixtures/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a
64
+ - test/fixtures/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d
65
+ - test/fixtures/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479
66
+ - test/fixtures/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a
67
+ - test/fixtures/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f
68
+ - test/fixtures/testrepo.git/objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd
69
+ - test/fixtures/testrepo.git/objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6
70
+ - test/fixtures/testrepo.git/objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644
71
+ - test/fixtures/testrepo.git/objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd
72
+ - test/fixtures/testrepo.git/objects/c4/dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b
73
+ - test/fixtures/testrepo.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
74
+ - test/fixtures/testrepo.git/objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1
75
+ - test/fixtures/testrepo.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92
76
+ - test/fixtures/testrepo.git/objects/fd/093bff70906175335656e6ce6ae05783708765
77
+ - test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx
78
+ - test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack
79
+ - test/fixtures/testrepo.git/packed-refs
80
+ - test/fixtures/testrepo.git/refs/heads/master
81
+ - test/fixtures/testrepo.git/refs/tags/v0.9
82
+ - test/fixtures/testrepo.git/refs/tags/v1.0
83
+ - test/index_test.rb
84
+ - test/lib_test.rb
85
+ - test/object_test.rb
86
+ - test/repo_pack_test.rb
87
+ - test/repo_test.rb
88
+ - test/tag_test.rb
89
+ - test/test_helper.rb
90
+ - test/tree_test.rb
91
+ - test/walker_test.rb
92
+ - ext/rugged/extconf.rb
93
+ has_rdoc: true
94
+ homepage: http://github.com/libgit2/rugged
95
+ licenses: []
96
+
97
+ post_install_message:
98
+ rdoc_options: []
99
+
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ requirements: []
121
+
122
+ rubyforge_project:
123
+ rubygems_version: 1.3.7
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: Rugged is a Ruby binding to the libgit2 linkable library
127
+ test_files: []
128
+