git-trip 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data.tar.gz.sig +2 -1
  2. data/History.txt +4 -0
  3. data/Manifest.txt +3 -56
  4. data/bin/git-trip +3 -0
  5. data/git-trip.gemspec +36 -0
  6. data/lib/git-trip.rb +3 -5
  7. data/lib/git-trip/errors.rb +1 -0
  8. data/lib/git-trip/gitter.rb +1 -0
  9. data/lib/git-trip/gitter/github.rb +68 -0
  10. data/lib/git-trip/gitter/uri.rb +27 -0
  11. data/spec/git-trip/errors_spec.rb +4 -0
  12. data/spec/git-trip/gitter/github_spec.rb +30 -0
  13. data/spec/git-trip/gitter/uri_spec.rb +4 -1
  14. data/spec/git-trip/gitter_spec.rb +8 -0
  15. metadata +5 -61
  16. metadata.gz.sig +0 -0
  17. data/vendor/grit/History.txt +0 -6
  18. data/vendor/grit/Manifest.txt +0 -53
  19. data/vendor/grit/README.txt +0 -213
  20. data/vendor/grit/Rakefile +0 -29
  21. data/vendor/grit/grit.gemspec +0 -16
  22. data/vendor/grit/lib/grit.rb +0 -37
  23. data/vendor/grit/lib/grit/actor.rb +0 -36
  24. data/vendor/grit/lib/grit/blob.rb +0 -117
  25. data/vendor/grit/lib/grit/commit.rb +0 -208
  26. data/vendor/grit/lib/grit/config.rb +0 -44
  27. data/vendor/grit/lib/grit/diff.rb +0 -70
  28. data/vendor/grit/lib/grit/errors.rb +0 -7
  29. data/vendor/grit/lib/grit/git.rb +0 -116
  30. data/vendor/grit/lib/grit/index.rb +0 -77
  31. data/vendor/grit/lib/grit/lazy.rb +0 -31
  32. data/vendor/grit/lib/grit/ref.rb +0 -110
  33. data/vendor/grit/lib/grit/repo.rb +0 -318
  34. data/vendor/grit/lib/grit/tree.rb +0 -99
  35. data/vendor/grit/test/fixtures/blame +0 -131
  36. data/vendor/grit/test/fixtures/cat_file_blob +0 -1
  37. data/vendor/grit/test/fixtures/cat_file_blob_size +0 -1
  38. data/vendor/grit/test/fixtures/diff_2 +0 -54
  39. data/vendor/grit/test/fixtures/diff_2f +0 -19
  40. data/vendor/grit/test/fixtures/diff_f +0 -15
  41. data/vendor/grit/test/fixtures/diff_i +0 -201
  42. data/vendor/grit/test/fixtures/diff_mode_only +0 -1152
  43. data/vendor/grit/test/fixtures/diff_new_mode +0 -17
  44. data/vendor/grit/test/fixtures/diff_p +0 -610
  45. data/vendor/grit/test/fixtures/for_each_ref +0 -0
  46. data/vendor/grit/test/fixtures/for_each_ref_remotes +0 -0
  47. data/vendor/grit/test/fixtures/for_each_ref_tags +0 -0
  48. data/vendor/grit/test/fixtures/ls_tree_a +0 -7
  49. data/vendor/grit/test/fixtures/ls_tree_b +0 -2
  50. data/vendor/grit/test/fixtures/ls_tree_commit +0 -3
  51. data/vendor/grit/test/fixtures/rev_list +0 -26
  52. data/vendor/grit/test/fixtures/rev_list_count +0 -655
  53. data/vendor/grit/test/fixtures/rev_list_single +0 -7
  54. data/vendor/grit/test/fixtures/rev_parse +0 -1
  55. data/vendor/grit/test/fixtures/show_empty_commit +0 -6
  56. data/vendor/grit/test/fixtures/simple_config +0 -2
  57. data/vendor/grit/test/helper.rb +0 -17
  58. data/vendor/grit/test/profile.rb +0 -21
  59. data/vendor/grit/test/suite.rb +0 -6
  60. data/vendor/grit/test/test_actor.rb +0 -35
  61. data/vendor/grit/test/test_blob.rb +0 -74
  62. data/vendor/grit/test/test_commit.rb +0 -182
  63. data/vendor/grit/test/test_config.rb +0 -58
  64. data/vendor/grit/test/test_diff.rb +0 -18
  65. data/vendor/grit/test/test_git.rb +0 -52
  66. data/vendor/grit/test/test_head.rb +0 -22
  67. data/vendor/grit/test/test_real.rb +0 -19
  68. data/vendor/grit/test/test_reality.rb +0 -17
  69. data/vendor/grit/test/test_remote.rb +0 -15
  70. data/vendor/grit/test/test_repo.rb +0 -278
  71. data/vendor/grit/test/test_tag.rb +0 -29
  72. data/vendor/grit/test/test_tree.rb +0 -91
@@ -1,22 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- class TestHead < Test::Unit::TestCase
4
- def setup
5
- @r = Repo.new(GRIT_REPO)
6
- Git.any_instance.expects(:for_each_ref).returns(fixture('for_each_ref'))
7
- end
8
-
9
- # inspect
10
-
11
- def test_inspect
12
- head = @r.heads.first
13
- assert_equal %Q{#<Grit::Head "#{head.name}">}, head.inspect
14
- end
15
-
16
- # heads with slashes
17
-
18
- def test_heads_with_slashes
19
- head = @r.heads.last
20
- assert_equal %Q{#<Grit::Head "mojombo/master">}, head.inspect
21
- end
22
- end
@@ -1,19 +0,0 @@
1
- # require File.dirname(__FILE__) + '/helper'
2
- #
3
- # class TestReal < Test::Unit::TestCase
4
- # def setup
5
- # `rm -fr /Users/tom/dev/sandbox/grittest.git`
6
- # `git --git-dir=/Users/tom/dev/sandbox/grittest.git init`
7
- # @repo = Repo.new('/Users/tom/dev/sandbox/grittest.git')
8
- # end
9
- #
10
- # def test_real
11
- # Grit.debug = true
12
- #
13
- # index = @repo.index
14
- # index.add('foo/bar/baz.txt', 'hello!')
15
- # index.add('foo/qux/bam.txt', 'world!')
16
- #
17
- # puts index.commit('first commit')
18
- # end
19
- # end
@@ -1,17 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- # class TestTreeRecursion < Test::Unit::TestCase
4
- # def test_
5
- # r = Repo.new("/Users/tom/dev/god")
6
- # t = r.tree("HEAD")
7
- #
8
- # recurse(t)
9
- # end
10
- #
11
- # def recurse(tree, indent = "")
12
- # tree.contents.each do |c|
13
- # # puts "#{indent}#{c.name} (#{c.id})"
14
- # recurse(c, indent + " ") if c.kind_of?(Tree)
15
- # end
16
- # end
17
- # end
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- class TestRemote < Test::Unit::TestCase
4
- def setup
5
- @r = Repo.new(GRIT_REPO)
6
- Git.any_instance.expects(:for_each_ref).returns(fixture('for_each_ref_remotes'))
7
- end
8
-
9
- # inspect
10
-
11
- def test_inspect
12
- remote = @r.remotes.first
13
- assert_equal %Q{#<Grit::Remote "#{remote.name}">}, remote.inspect
14
- end
15
- end
@@ -1,278 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- class TestRepo < Test::Unit::TestCase
4
- def setup
5
- @r = Repo.new(GRIT_REPO)
6
- end
7
-
8
- # new
9
-
10
- def test_new_should_raise_on_invalid_repo_location
11
- assert_raise(InvalidGitRepositoryError) do
12
- Repo.new("/tmp")
13
- end
14
- end
15
-
16
- def test_new_should_raise_on_non_existant_path
17
- assert_raise(NoSuchPathError) do
18
- Repo.new("/foobar")
19
- end
20
- end
21
-
22
- # descriptions
23
-
24
- def test_description
25
- assert_equal "Unnamed repository; edit this file to name it for gitweb.", @r.description
26
- end
27
-
28
- # refs
29
-
30
- def test_refs_should_return_array_of_ref_objects
31
- @r.refs.each do |ref|
32
- assert ref.is_a? Grit::Ref
33
- end
34
- end
35
-
36
- # heads
37
-
38
- def test_heads_should_return_array_of_head_objects
39
- @r.heads.each do |head|
40
- assert_equal Grit::Head, head.class
41
- end
42
- end
43
-
44
- def test_heads_should_populate_head_data
45
- Git.any_instance.expects(:for_each_ref).returns(fixture('for_each_ref'))
46
-
47
- head = @r.heads.first
48
-
49
- assert_equal 'master', head.name
50
- assert_equal '634396b2f541a9f2d58b00be1a07f0c358b999b3', head.commit.id
51
- end
52
-
53
- # branches
54
-
55
- def test_branches
56
- # same as heads
57
- end
58
-
59
- # commits
60
-
61
- def test_commits
62
- Git.any_instance.expects(:rev_list).returns(fixture('rev_list'))
63
-
64
- commits = @r.commits('master', 10)
65
-
66
- c = commits[0]
67
- assert_equal '4c8124ffcf4039d292442eeccabdeca5af5c5017', c.id
68
- assert_equal ["634396b2f541a9f2d58b00be1a07f0c358b999b3"], c.parents.map { |p| p.id }
69
- assert_equal "672eca9b7f9e09c22dcb128c283e8c3c8d7697a4", c.tree.id
70
- assert_equal "Tom Preston-Werner", c.author.name
71
- assert_equal "tom@mojombo.com", c.author.email
72
- assert_equal Time.at(1191999972), c.authored_date
73
- assert_equal "Tom Preston-Werner", c.committer.name
74
- assert_equal "tom@mojombo.com", c.committer.email
75
- assert_equal Time.at(1191999972), c.committed_date
76
- assert_equal "implement Grit#heads", c.message
77
-
78
- c = commits[1]
79
- assert_equal [], c.parents
80
-
81
- c = commits[2]
82
- assert_equal ["6e64c55896aabb9a7d8e9f8f296f426d21a78c2c", "7f874954efb9ba35210445be456c74e037ba6af2"], c.parents.map { |p| p.id }
83
- assert_equal "Merge branch 'site'\n\n * Some other stuff\n * just one more", c.message
84
- assert_equal "Merge branch 'site'", c.short_message
85
- end
86
-
87
- # commit_count
88
-
89
- def test_commit_count
90
- Git.any_instance.expects(:rev_list).with({}, 'master').returns(fixture('rev_list_count'))
91
-
92
- assert_equal 655, @r.commit_count('master')
93
- end
94
-
95
- # commit
96
-
97
- def test_commit
98
- commit = @r.commit('634396b2f541a9f2d58b00be1a07f0c358b999b3')
99
-
100
- assert_equal "634396b2f541a9f2d58b00be1a07f0c358b999b3", commit.id
101
- end
102
-
103
- # tree
104
-
105
- def test_tree
106
- Git.any_instance.expects(:ls_tree).returns(fixture('ls_tree_a'))
107
- tree = @r.tree('master')
108
-
109
- assert_equal 4, tree.contents.select { |c| c.instance_of?(Blob) }.size
110
- assert_equal 3, tree.contents.select { |c| c.instance_of?(Tree) }.size
111
- end
112
-
113
- # blob
114
-
115
- def test_blob
116
- Git.any_instance.expects(:cat_file).returns(fixture('cat_file_blob'))
117
- blob = @r.blob("abc")
118
- assert_equal "Hello world", blob.data
119
- end
120
-
121
- # init_bare
122
-
123
- def test_init_bare
124
- Git.any_instance.expects(:init).returns(true)
125
- Repo.expects(:new).with("/foo/bar.git")
126
- Repo.init_bare("/foo/bar.git")
127
- end
128
-
129
- def test_init_bare_with_options
130
- Git.any_instance.expects(:init).with(
131
- :template => "/baz/sweet").returns(true)
132
- Repo.expects(:new).with("/foo/bar.git")
133
- Repo.init_bare("/foo/bar.git", :template => "/baz/sweet")
134
- end
135
-
136
- # fork_bare
137
-
138
- def test_fork_bare
139
- Git.any_instance.expects(:clone).with(
140
- {:bare => true, :shared => true},
141
- "#{absolute_project_path}/.git",
142
- "/foo/bar.git").returns(nil)
143
- Repo.expects(:new)
144
-
145
- @r.fork_bare("/foo/bar.git")
146
- end
147
-
148
- def test_fork_bare_with_options
149
- Git.any_instance.expects(:clone).with(
150
- {:bare => true, :shared => true, :template => '/awesome'},
151
- "#{absolute_project_path}/.git",
152
- "/foo/bar.git").returns(nil)
153
- Repo.expects(:new)
154
-
155
- @r.fork_bare("/foo/bar.git", :template => '/awesome')
156
- end
157
-
158
- # diff
159
-
160
- def test_diff
161
- Git.any_instance.expects(:diff).with({}, 'master^', 'master', '--')
162
- @r.diff('master^', 'master')
163
-
164
- Git.any_instance.expects(:diff).with({}, 'master^', 'master', '--', 'foo/bar')
165
- @r.diff('master^', 'master', 'foo/bar')
166
-
167
- Git.any_instance.expects(:diff).with({}, 'master^', 'master', '--', 'foo/bar', 'foo/baz')
168
- @r.diff('master^', 'master', 'foo/bar', 'foo/baz')
169
- end
170
-
171
- # commit_diff
172
-
173
- def test_diff
174
- Git.any_instance.expects(:diff).returns(fixture('diff_p'))
175
- diffs = @r.commit_diff('master')
176
-
177
- assert_equal 15, diffs.size
178
- end
179
-
180
- # init bare
181
-
182
- # archive
183
-
184
- def test_archive_tar
185
- @r.archive_tar
186
- end
187
-
188
- # archive_tar_gz
189
-
190
- def test_archive_tar_gz
191
- @r.archive_tar_gz
192
- end
193
-
194
- # enable_daemon_serve
195
-
196
- def test_enable_daemon_serve
197
- FileUtils.expects(:touch).with(File.join(@r.path, 'git-daemon-export-ok'))
198
- @r.enable_daemon_serve
199
- end
200
-
201
- # disable_daemon_serve
202
-
203
- def test_disable_daemon_serve
204
- FileUtils.expects(:rm_f).with(File.join(@r.path, 'git-daemon-export-ok'))
205
- @r.disable_daemon_serve
206
- end
207
-
208
- # alternates
209
-
210
- def test_alternates_with_two_alternates
211
- File.expects(:exist?).with("#{absolute_project_path}/.git/objects/info/alternates").returns(true)
212
- File.expects(:read).returns("/path/to/repo1/.git/objects\n/path/to/repo2.git/objects\n")
213
-
214
- assert_equal ["/path/to/repo1/.git/objects", "/path/to/repo2.git/objects"], @r.alternates
215
- end
216
-
217
- def test_alternates_no_file
218
- File.expects(:exist?).returns(false)
219
-
220
- assert_equal [], @r.alternates
221
- end
222
-
223
- # alternates=
224
-
225
- def test_alternates_setter_ok
226
- alts = %w{/path/to/repo.git/objects /path/to/repo2.git/objects}
227
-
228
- alts.each do |alt|
229
- File.expects(:exist?).with(alt).returns(true)
230
- end
231
-
232
- File.any_instance.expects(:write).with(alts.join("\n"))
233
-
234
- assert_nothing_raised do
235
- @r.alternates = alts
236
- end
237
- end
238
-
239
- def test_alternates_setter_bad
240
- alts = %w{/path/to/repo.git/objects}
241
-
242
- alts.each do |alt|
243
- File.expects(:exist?).with(alt).returns(false)
244
- end
245
-
246
- File.any_instance.expects(:write).never
247
-
248
- assert_raise RuntimeError do
249
- @r.alternates = alts
250
- end
251
- end
252
-
253
- def test_alternates_setter_empty
254
- File.expects(:delete)
255
-
256
- @r.alternates = []
257
- end
258
-
259
- # inspect
260
-
261
- def test_inspect
262
- assert_equal %Q{#<Grit::Repo "#{File.expand_path(GRIT_REPO)}/.git">}, @r.inspect
263
- end
264
-
265
- # log
266
-
267
- def test_log
268
- Git.any_instance.expects(:log).times(2).with({:pretty => 'raw'}, 'master').returns(fixture('rev_list'))
269
-
270
- assert_equal '4c8124ffcf4039d292442eeccabdeca5af5c5017', @r.log.first.id
271
- assert_equal 'ab25fd8483882c3bda8a458ad2965d2248654335', @r.log.last.id
272
- end
273
-
274
- def test_log_with_path_and_options
275
- Git.any_instance.expects(:log).with({:pretty => 'raw', :max_count => 1}, 'master', '--', 'file.rb').returns(fixture('rev_list'))
276
- @r.log('master', 'file.rb', :max_count => 1)
277
- end
278
- end
@@ -1,29 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- class TestTag < Test::Unit::TestCase
4
- def setup
5
- @r = Repo.new(GRIT_REPO)
6
- end
7
-
8
- # list_from_string
9
-
10
- def test_list_from_string
11
- Git.any_instance.expects(:for_each_ref).returns(fixture('for_each_ref_tags'))
12
-
13
- tags = @r.tags
14
-
15
- assert_equal 1, tags.size
16
- assert_equal 'v0.7.1', tags.first.name
17
- assert_equal '634396b2f541a9f2d58b00be1a07f0c358b999b3', tags.first.commit.id
18
- end
19
-
20
- # inspect
21
-
22
- def test_inspect
23
- Git.any_instance.expects(:for_each_ref).returns(fixture('for_each_ref'))
24
-
25
- tag = @r.tags.first
26
-
27
- assert_equal %Q{#<Grit::Tag "#{tag.name}">}, tag.inspect
28
- end
29
- end
@@ -1,91 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- class TestTree < Test::Unit::TestCase
4
- def setup
5
- @r = Repo.new(GRIT_REPO)
6
- @t = Tree.allocate
7
- end
8
-
9
- # contents
10
-
11
- def test_contents_should_cache
12
- Git.any_instance.expects(:ls_tree).returns(
13
- fixture('ls_tree_a'),
14
- fixture('ls_tree_b')
15
- ).times(2)
16
- tree = @r.tree('master')
17
-
18
- child = tree.contents.last
19
-
20
- child.contents
21
- child.contents
22
- end
23
-
24
- # content_from_string
25
-
26
- def test_content_from_string_tree_should_return_tree
27
- text = fixture('ls_tree_a').split("\n").last
28
-
29
- tree = @t.content_from_string(nil, text)
30
-
31
- assert_equal Tree, tree.class
32
- assert_equal "650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44", tree.id
33
- assert_equal "040000", tree.mode
34
- assert_equal "test", tree.name
35
- end
36
-
37
- def test_content_from_string_tree_should_return_blob
38
- text = fixture('ls_tree_b').split("\n").first
39
-
40
- tree = @t.content_from_string(nil, text)
41
-
42
- assert_equal Blob, tree.class
43
- assert_equal "aa94e396335d2957ca92606f909e53e7beaf3fbb", tree.id
44
- assert_equal "100644", tree.mode
45
- assert_equal "grit.rb", tree.name
46
- end
47
-
48
- def test_content_from_string_tree_should_return_commit
49
- text = fixture('ls_tree_commit').split("\n")[1]
50
-
51
- tree = @t.content_from_string(nil, text)
52
-
53
- assert_nil tree
54
- end
55
-
56
- def test_content_from_string_invalid_type_should_raise
57
- assert_raise(RuntimeError) do
58
- @t.content_from_string(nil, "040000 bogus 650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44 test")
59
- end
60
- end
61
-
62
- # /
63
-
64
- def test_slash
65
- Git.any_instance.expects(:ls_tree).returns(
66
- fixture('ls_tree_a')
67
- )
68
- tree = @r.tree('master')
69
-
70
- assert_equal 'aa06ba24b4e3f463b3c4a85469d0fb9e5b421cf8', (tree/'lib').id
71
- assert_equal '8b1e02c0fb554eed2ce2ef737a68bb369d7527df', (tree/'README.txt').id
72
- end
73
-
74
- def test_slash_with_commits
75
- Git.any_instance.expects(:ls_tree).returns(
76
- fixture('ls_tree_commit')
77
- )
78
- tree = @r.tree('master')
79
-
80
- assert_nil tree/'bar'
81
- assert_equal '2afb47bcedf21663580d5e6d2f406f08f3f65f19', (tree/'foo').id
82
- assert_equal 'f623ee576a09ca491c4a27e48c0dfe04be5f4a2e', (tree/'baz').id
83
- end
84
-
85
- # inspect
86
-
87
- def test_inspect
88
- @t = Tree.create(@r, :id => 'abc')
89
- assert_equal %Q{#<Grit::Tree "abc">}, @t.inspect
90
- end
91
- end