mojombo-grit 0.8.1 → 0.9.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.
Files changed (59) hide show
  1. data/History.txt +7 -0
  2. data/Manifest.txt +18 -1
  3. data/grit.gemspec +56 -10
  4. data/lib/{mojombo-grit.rb → grit.rb} +20 -4
  5. data/lib/grit/commit.rb +32 -11
  6. data/lib/grit/commit_stats.rb +104 -0
  7. data/lib/grit/git-ruby.rb +182 -0
  8. data/lib/grit/git-ruby/commit_db.rb +52 -0
  9. data/lib/grit/git-ruby/file_index.rb +186 -0
  10. data/lib/grit/git-ruby/git_object.rb +344 -0
  11. data/lib/grit/git-ruby/internal/loose.rb +136 -0
  12. data/lib/grit/git-ruby/internal/mmap.rb +58 -0
  13. data/lib/grit/git-ruby/internal/pack.rb +382 -0
  14. data/lib/grit/git-ruby/internal/raw_object.rb +37 -0
  15. data/lib/grit/git-ruby/object.rb +319 -0
  16. data/lib/grit/git-ruby/repository.rb +729 -0
  17. data/lib/grit/git.rb +33 -15
  18. data/lib/grit/head.rb +6 -15
  19. data/lib/grit/index.rb +121 -0
  20. data/lib/grit/ref.rb +95 -0
  21. data/lib/grit/repo.rb +95 -6
  22. data/lib/grit/status.rb +151 -0
  23. data/lib/grit/tree.rb +3 -2
  24. data/test/test_blob.rb +5 -0
  25. data/test/test_commit.rb +7 -5
  26. data/test/test_diff.rb +1 -1
  27. data/test/test_git.rb +20 -2
  28. data/test/test_grit.rb +32 -0
  29. data/test/test_head.rb +30 -5
  30. data/test/test_real.rb +8 -6
  31. data/test/test_remote.rb +14 -0
  32. data/test/test_repo.rb +86 -79
  33. data/test/test_tag.rb +2 -6
  34. data/test/test_tree.rb +5 -0
  35. metadata +40 -40
  36. data/test/fixtures/blame +0 -131
  37. data/test/fixtures/cat_file_blob +0 -1
  38. data/test/fixtures/cat_file_blob_size +0 -1
  39. data/test/fixtures/diff_2 +0 -54
  40. data/test/fixtures/diff_2f +0 -19
  41. data/test/fixtures/diff_f +0 -15
  42. data/test/fixtures/diff_i +0 -201
  43. data/test/fixtures/diff_mode_only +0 -1152
  44. data/test/fixtures/diff_new_mode +0 -17
  45. data/test/fixtures/diff_p +0 -610
  46. data/test/fixtures/for_each_ref +0 -0
  47. data/test/fixtures/for_each_ref_tags +0 -0
  48. data/test/fixtures/ls_tree_a +0 -7
  49. data/test/fixtures/ls_tree_b +0 -2
  50. data/test/fixtures/ls_tree_commit +0 -3
  51. data/test/fixtures/rev_list +0 -26
  52. data/test/fixtures/rev_list_count +0 -655
  53. data/test/fixtures/rev_list_single +0 -7
  54. data/test/fixtures/rev_parse +0 -1
  55. data/test/fixtures/show_empty_commit +0 -6
  56. data/test/fixtures/simple_config +0 -2
  57. data/test/helper.rb +0 -17
  58. data/test/profile.rb +0 -21
  59. data/test/suite.rb +0 -6
data/test/test_tag.rb CHANGED
@@ -8,20 +8,16 @@ class TestTag < Test::Unit::TestCase
8
8
  # list_from_string
9
9
 
10
10
  def test_list_from_string
11
- Git.any_instance.expects(:for_each_ref).returns(fixture('for_each_ref_tags'))
12
-
13
11
  tags = @r.tags
14
12
 
15
13
  assert_equal 1, tags.size
16
- assert_equal 'v0.7.1', tags.first.name
17
- assert_equal '634396b2f541a9f2d58b00be1a07f0c358b999b3', tags.first.commit.id
14
+ assert_equal 'v0.7.0', tags.first.name
15
+ assert_equal 'f0055fda16c18fd8b27986dbf038c735b82198d7', tags.first.commit.id
18
16
  end
19
17
 
20
18
  # inspect
21
19
 
22
20
  def test_inspect
23
- Git.any_instance.expects(:for_each_ref).returns(fixture('for_each_ref'))
24
-
25
21
  tag = @r.tags.first
26
22
 
27
23
  assert_equal %Q{#<Grit::Tag "#{tag.name}">}, tag.inspect
data/test/test_tree.rb CHANGED
@@ -7,6 +7,11 @@ class TestTree < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  # contents
10
+ def test_nosuch_tree
11
+ t = @r.tree('blahblah')
12
+ assert t.contents.is_a?(Array)
13
+ assert t.is_a?(Tree)
14
+ end
10
15
 
11
16
  def test_contents_should_cache
12
17
  Git.any_instance.expects(:ls_tree).returns(
metadata CHANGED
@@ -1,10 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mojombo-grit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
8
+ - Scott Chacon
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
@@ -12,6 +13,15 @@ cert_chain: []
12
13
  date: 2008-04-24 00:00:00 -07:00
13
14
  default_executable:
14
15
  dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: diff-lcs
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
15
25
  - !ruby/object:Gem::Dependency
16
26
  name: mime-types
17
27
  version_requirement:
@@ -21,6 +31,15 @@ dependencies:
21
31
  - !ruby/object:Gem::Version
22
32
  version: 0.0.0
23
33
  version:
34
+ - !ruby/object:Gem::Dependency
35
+ name: open4
36
+ version_requirement:
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.0.0
42
+ version:
24
43
  description: Grit is a Ruby library for extracting information from a git repository in and object oriented manner.
25
44
  email: tom@rubyisawesome.com
26
45
  executables: []
@@ -37,57 +56,36 @@ files:
37
56
  - README.txt
38
57
  - Rakefile
39
58
  - grit.gemspec
40
- - lib/grit.rb
41
59
  - lib/grit/actor.rb
42
60
  - lib/grit/blob.rb
43
61
  - lib/grit/commit.rb
62
+ - lib/grit/commit_stats.rb
44
63
  - lib/grit/config.rb
45
64
  - lib/grit/diff.rb
46
65
  - lib/grit/errors.rb
66
+ - lib/grit/git-ruby/commit_db.rb
67
+ - lib/grit/git-ruby/file_index.rb
68
+ - lib/grit/git-ruby/git_object.rb
69
+ - lib/grit/git-ruby/internal
70
+ - lib/grit/git-ruby/internal/loose.rb
71
+ - lib/grit/git-ruby/internal/mmap.rb
72
+ - lib/grit/git-ruby/internal/pack.rb
73
+ - lib/grit/git-ruby/internal/raw_object.rb
74
+ - lib/grit/git-ruby/object.rb
75
+ - lib/grit/git-ruby/repository.rb
76
+ - lib/grit/git-ruby.rb
47
77
  - lib/grit/git.rb
48
78
  - lib/grit/head.rb
79
+ - lib/grit/index.rb
49
80
  - lib/grit/lazy.rb
81
+ - lib/grit/ref.rb
50
82
  - lib/grit/repo.rb
83
+ - lib/grit/status.rb
51
84
  - lib/grit/tag.rb
52
85
  - lib/grit/tree.rb
53
- - test/fixtures/blame
54
- - test/fixtures/cat_file_blob
55
- - test/fixtures/cat_file_blob_size
56
- - test/fixtures/diff_2
57
- - test/fixtures/diff_2f
58
- - test/fixtures/diff_f
59
- - test/fixtures/diff_i
60
- - test/fixtures/diff_mode_only
61
- - test/fixtures/diff_new_mode
62
- - test/fixtures/diff_p
63
- - test/fixtures/for_each_ref
64
- - test/fixtures/for_each_ref_tags
65
- - test/fixtures/ls_tree_a
66
- - test/fixtures/ls_tree_b
67
- - test/fixtures/ls_tree_commit
68
- - test/fixtures/rev_list
69
- - test/fixtures/rev_list_count
70
- - test/fixtures/rev_list_single
71
- - test/fixtures/rev_parse
72
- - test/fixtures/show_empty_commit
73
- - test/fixtures/simple_config
74
- - test/helper.rb
75
- - test/profile.rb
76
- - test/suite.rb
77
- - test/test_actor.rb
78
- - test/test_blob.rb
79
- - test/test_commit.rb
80
- - test/test_config.rb
81
- - test/test_diff.rb
82
- - test/test_git.rb
83
- - test/test_head.rb
84
- - test/test_reality.rb
85
- - test/test_repo.rb
86
- - test/test_tag.rb
87
- - test/test_tree.rb
88
- - test/test_real.rb
86
+ - lib/grit.rb
89
87
  has_rdoc: true
90
- homepage: http://github.com/mojombo/grit
88
+ homepage: http://github.com/schacon/grit
91
89
  post_install_message:
92
90
  rdoc_options:
93
91
  - --main
@@ -109,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
107
  requirements: []
110
108
 
111
109
  rubyforge_project:
112
- rubygems_version: 1.0.1
110
+ rubygems_version: 1.2.0
113
111
  signing_key:
114
112
  specification_version: 2
115
113
  summary: Object model interface to a git repo
@@ -120,9 +118,11 @@ test_files:
120
118
  - test/test_config.rb
121
119
  - test/test_diff.rb
122
120
  - test/test_git.rb
121
+ - test/test_grit.rb
123
122
  - test/test_head.rb
124
123
  - test/test_real.rb
125
124
  - test/test_reality.rb
125
+ - test/test_remote.rb
126
126
  - test/test_repo.rb
127
127
  - test/test_tag.rb
128
128
  - test/test_tree.rb
data/test/fixtures/blame DELETED
@@ -1,131 +0,0 @@
1
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 1 1 7
2
- author Tom Preston-Werner
3
- author-mail <tom@mojombo.com>
4
- author-time 1191997100
5
- author-tz -0700
6
- committer Tom Preston-Werner
7
- committer-mail <tom@mojombo.com>
8
- committer-time 1191997100
9
- committer-tz -0700
10
- filename lib/grit.rb
11
- summary initial grit setup
12
- boundary
13
- $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
14
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 2 2
15
-
16
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 3 3
17
- # core
18
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 4 4
19
-
20
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 5 5
21
- # stdlib
22
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 6 6
23
-
24
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 7 7
25
- # internal requires
26
- 3b1930208a82457747d76729ae088e90edca4673 8 8 1
27
- author Tom Preston-Werner
28
- author-mail <tom@mojombo.com>
29
- author-time 1192267241
30
- author-tz -0700
31
- committer Tom Preston-Werner
32
- committer-mail <tom@mojombo.com>
33
- committer-time 1192267241
34
- committer-tz -0700
35
- filename lib/grit.rb
36
- summary big refactor to do lazy loading
37
- require 'grit/lazy'
38
- 4c8124ffcf4039d292442eeccabdeca5af5c5017 8 9 1
39
- author Tom Preston-Werner
40
- author-mail <tom@mojombo.com>
41
- author-time 1191999972
42
- author-tz -0700
43
- committer Tom Preston-Werner
44
- committer-mail <tom@mojombo.com>
45
- committer-time 1191999972
46
- committer-tz -0700
47
- filename lib/grit.rb
48
- summary implement Grit#heads
49
- require 'grit/errors'
50
- d01a4cfad6ea50285c4710243e3cbe019d381eba 9 10 1
51
- author Tom Preston-Werner
52
- author-mail <tom@mojombo.com>
53
- author-time 1192032303
54
- author-tz -0700
55
- committer Tom Preston-Werner
56
- committer-mail <tom@mojombo.com>
57
- committer-time 1192032303
58
- committer-tz -0700
59
- filename lib/grit.rb
60
- summary convert to Grit module, refactor to be more OO
61
- require 'grit/git'
62
- 4c8124ffcf4039d292442eeccabdeca5af5c5017 9 11 1
63
- require 'grit/head'
64
- a47fd41f3aa4610ea527dcc1669dfdb9c15c5425 10 12 1
65
- author Tom Preston-Werner
66
- author-mail <tom@mojombo.com>
67
- author-time 1192002639
68
- author-tz -0700
69
- committer Tom Preston-Werner
70
- committer-mail <tom@mojombo.com>
71
- committer-time 1192002639
72
- committer-tz -0700
73
- filename lib/grit.rb
74
- summary add more comments throughout
75
- require 'grit/commit'
76
- b17b974691f0a26f26908495d24d9c4c718920f8 13 13 1
77
- author Tom Preston-Werner
78
- author-mail <tom@mojombo.com>
79
- author-time 1192271832
80
- author-tz -0700
81
- committer Tom Preston-Werner
82
- committer-mail <tom@mojombo.com>
83
- committer-time 1192271832
84
- committer-tz -0700
85
- filename lib/grit.rb
86
- summary started implementing Tree
87
- require 'grit/tree'
88
- 74fd66519e983a0f29e16a342a6059dbffe36020 14 14 1
89
- author Tom Preston-Werner
90
- author-mail <tom@mojombo.com>
91
- author-time 1192317005
92
- author-tz -0700
93
- committer Tom Preston-Werner
94
- committer-mail <tom@mojombo.com>
95
- committer-time 1192317005
96
- committer-tz -0700
97
- filename lib/grit.rb
98
- summary add Blob
99
- require 'grit/blob'
100
- d01a4cfad6ea50285c4710243e3cbe019d381eba 12 15 1
101
- require 'grit/repo'
102
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 9 16 1
103
-
104
- d01a4cfad6ea50285c4710243e3cbe019d381eba 14 17 1
105
- module Grit
106
- b6e1b765e0c15586a2c5b9832854f95defd71e1f 18 18 6
107
- author Tom Preston-Werner
108
- author-mail <tom@mojombo.com>
109
- author-time 1192860483
110
- author-tz -0700
111
- committer Tom Preston-Werner
112
- committer-mail <tom@mojombo.com>
113
- committer-time 1192860483
114
- committer-tz -0700
115
- filename lib/grit.rb
116
- summary implement Repo.init_bare
117
- class << self
118
- b6e1b765e0c15586a2c5b9832854f95defd71e1f 19 19
119
- attr_accessor :debug
120
- b6e1b765e0c15586a2c5b9832854f95defd71e1f 20 20
121
- end
122
- b6e1b765e0c15586a2c5b9832854f95defd71e1f 21 21
123
-
124
- b6e1b765e0c15586a2c5b9832854f95defd71e1f 22 22
125
- self.debug = false
126
- b6e1b765e0c15586a2c5b9832854f95defd71e1f 23 23
127
-
128
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 11 24 2
129
- VERSION = '1.0.0'
130
- 634396b2f541a9f2d58b00be1a07f0c358b999b3 12 25
131
- end
@@ -1 +0,0 @@
1
- Hello world
@@ -1 +0,0 @@
1
- 11
data/test/fixtures/diff_2 DELETED
@@ -1,54 +0,0 @@
1
- diff --git a/lib/grit/commit.rb b/lib/grit/commit.rb
2
- index a093bb1db8e884cccf396b297259181d1caebed4..80fd3d527f269ecbd570b65b8e21fd85baedb6e9 100644
3
- --- a/lib/grit/commit.rb
4
- +++ b/lib/grit/commit.rb
5
- @@ -156,12 +156,8 @@ module Grit
6
-
7
- def diffs
8
- if parents.empty?
9
- - diff = @repo.git.show({:full_index => true, :pretty => 'raw'}, @id)
10
- - if diff =~ /diff --git a/
11
- - diff = diff.sub(/.+?(diff --git a)/m, '\1')
12
- - else
13
- - diff = ''
14
- - end
15
- + diff = @repo.git.show({:full_index => true, :pretty => 'raw'}, @id)
16
- + diff = diff.sub(/.+?(diff --git a)/m, '\1')
17
- Diff.list_from_string(@repo, diff)
18
- else
19
- self.class.diff(@repo, parents.first.id, @id)
20
- diff --git a/test/fixtures/show_empty_commit b/test/fixtures/show_empty_commit
21
- deleted file mode 100644
22
- index ea25e32a409fdf74c1b9268820108d1c16dcc553..0000000000000000000000000000000000000000
23
- --- a/test/fixtures/show_empty_commit
24
- +++ /dev/null
25
- @@ -1,6 +0,0 @@
26
- -commit 1e3824339762bd48316fe87bfafc853732d43264
27
- -tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
28
- -author Tom Preston-Werner <tom@mojombo.com> 1157392833 +0000
29
- -committer Tom Preston-Werner <tom@mojombo.com> 1157392833 +0000
30
- -
31
- - initial directory structure
32
- diff --git a/test/test_commit.rb b/test/test_commit.rb
33
- index fdeb9000089b052f0b31a845e0173e9b089e06a0..bdbc450e08084d7d611e985cfa12fb424cab29b2 100644
34
- --- a/test/test_commit.rb
35
- +++ b/test/test_commit.rb
36
- @@ -98,18 +98,6 @@ class TestCommit < Test::Unit::TestCase
37
- assert_equal true, diffs[5].new_file
38
- end
39
-
40
- - def test_diffs_on_initial_import_with_empty_commit
41
- - Git.any_instance.expects(:show).with(
42
- - {:full_index => true, :pretty => 'raw'},
43
- - '634396b2f541a9f2d58b00be1a07f0c358b999b3'
44
- - ).returns(fixture('show_empty_commit'))
45
- -
46
- - @c = Commit.create(@r, :id => '634396b2f541a9f2d58b00be1a07f0c358b999b3')
47
- - diffs = @c.diffs
48
- -
49
- - assert_equal [], diffs
50
- - end
51
- -
52
- # to_s
53
-
54
- def test_to_s
@@ -1,19 +0,0 @@
1
- diff --git a/lib/grit/commit.rb b/lib/grit/commit.rb
2
- index a093bb1db8e884cccf396b297259181d1caebed4..80fd3d527f269ecbd570b65b8e21fd85baedb6e9 100644
3
- --- a/lib/grit/commit.rb
4
- +++ b/lib/grit/commit.rb
5
- @@ -156,12 +156,8 @@ module Grit
6
-
7
- def diffs
8
- if parents.empty?
9
- - diff = @repo.git.show({:full_index => true, :pretty => 'raw'}, @id)
10
- - if diff =~ /diff --git a/
11
- - diff = diff.sub(/.+?(diff --git a)/m, '\1')
12
- - else
13
- - diff = ''
14
- - end
15
- + diff = @repo.git.show({:full_index => true, :pretty => 'raw'}, @id)
16
- + diff = diff.sub(/.+?(diff --git a)/m, '\1')
17
- Diff.list_from_string(@repo, diff)
18
- else
19
- self.class.diff(@repo, parents.first.id, @id)
data/test/fixtures/diff_f DELETED
@@ -1,15 +0,0 @@
1
- diff --git a/lib/grit/diff.rb b/lib/grit/diff.rb
2
- index 537955bb86a8ceaa19aea89e75ccbea5ce6f2698..00b0b4a67eca9242db5f8991e99625acd55f040c 100644
3
- --- a/lib/grit/diff.rb
4
- +++ b/lib/grit/diff.rb
5
- @@ -27,6 +27,10 @@ module Grit
6
- while !lines.empty?
7
- m, a_path, b_path = *lines.shift.match(%r{^diff --git a/(\S+) b/(\S+)$})
8
-
9
- + if lines.first =~ /^old mode/
10
- + 2.times { lines.shift }
11
- + end
12
- +
13
- new_file = false
14
- deleted_file = false
15
-
data/test/fixtures/diff_i DELETED
@@ -1,201 +0,0 @@
1
- commit 634396b2f541a9f2d58b00be1a07f0c358b999b3
2
- Author: Tom Preston-Werner <tom@mojombo.com>
3
- Date: Tue Oct 9 23:18:20 2007 -0700
4
-
5
- initial grit setup
6
-
7
- diff --git a/History.txt b/History.txt
8
- new file mode 100644
9
- index 0000000000000000000000000000000000000000..81d2c27608b352814cbe979a6acd678d30219678
10
- --- /dev/null
11
- +++ b/History.txt
12
- @@ -0,0 +1,5 @@
13
- +== 1.0.0 / 2007-10-09
14
- +
15
- +* 1 major enhancement
16
- + * Birthday!
17
- +
18
- diff --git a/Manifest.txt b/Manifest.txt
19
- new file mode 100644
20
- index 0000000000000000000000000000000000000000..641972d82c6d1b51122274ae8f6a0ecdfb56ee22
21
- --- /dev/null
22
- +++ b/Manifest.txt
23
- @@ -0,0 +1,7 @@
24
- +History.txt
25
- +Manifest.txt
26
- +README.txt
27
- +Rakefile
28
- +bin/grit
29
- +lib/grit.rb
30
- +test/test_grit.rb
31
-
32
- diff --git a/README.txt b/README.txt
33
- new file mode 100644
34
- index 0000000000000000000000000000000000000000..8b1e02c0fb554eed2ce2ef737a68bb369d7527df
35
- --- /dev/null
36
- +++ b/README.txt
37
- @@ -0,0 +1,48 @@
38
- +grit
39
- + by FIX (your name)
40
- + FIX (url)
41
- +
42
- +== DESCRIPTION:
43
- +
44
- +FIX (describe your package)
45
- +
46
- +== FEATURES/PROBLEMS:
47
- +
48
- +* FIX (list of features or problems)
49
- +
50
- +== SYNOPSIS:
51
- +
52
- + FIX (code sample of usage)
53
- +
54
- +== REQUIREMENTS:
55
- +
56
- +* FIX (list of requirements)
57
- +
58
- +== INSTALL:
59
- +
60
- +* FIX (sudo gem install, anything else)
61
- +
62
- +== LICENSE:
63
- +
64
- +(The MIT License)
65
- +
66
- +Copyright (c) 2007 FIX
67
- +
68
- +Permission is hereby granted, free of charge, to any person obtaining
69
- +a copy of this software and associated documentation files (the
70
- +'Software'), to deal in the Software without restriction, including
71
- +without limitation the rights to use, copy, modify, merge, publish,
72
- +distribute, sublicense, and/or sell copies of the Software, and to
73
- +permit persons to whom the Software is furnished to do so, subject to
74
- +the following conditions:
75
- +
76
- +The above copyright notice and this permission notice shall be
77
- +included in all copies or substantial portions of the Software.
78
- +
79
- +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
80
- +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81
- +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
82
- +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
83
- +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
84
- +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
85
- +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86
- diff --git a/Rakefile b/Rakefile
87
- new file mode 100644
88
- index 0000000000000000000000000000000000000000..ff69c3684a18592c741332b290492aa39d980e02
89
- --- /dev/null
90
- +++ b/Rakefile
91
- @@ -0,0 +1,17 @@
92
- +# -*- ruby -*-
93
- +
94
- +require 'rubygems'
95
- +require 'hoe'
96
- +require './lib/grit.rb'
97
- +
98
- +Hoe.new('grit', Grit::VERSION) do |p|
99
- + p.rubyforge_name = 'grit'
100
- + # p.author = 'FIX'
101
- + # p.email = 'FIX'
102
- + # p.summary = 'FIX'
103
- + # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
104
- + # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
105
- + p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
106
- +end
107
- +
108
- +# vim: syntax=Ruby
109
- diff --git a/bin/grit b/bin/grit
110
- new file mode 100644
111
- index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
112
- diff --git a/lib/grit.rb b/lib/grit.rb
113
- new file mode 100644
114
- index 0000000000000000000000000000000000000000..32cec87d1e78946a827ddf6a8776be4d81dcf1d1
115
- --- /dev/null
116
- +++ b/lib/grit.rb
117
- @@ -0,0 +1,12 @@
118
- +$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
119
- +
120
- +# core
121
- +
122
- +# stdlib
123
- +
124
- +# internal requires
125
- +require 'grit/grit'
126
- +
127
- +class Grit
128
- + VERSION = '1.0.0'
129
- +end
130
-
131
- diff --git a/lib/grit/errors.rb b/lib/grit/errors.rb
132
- new file mode 100644
133
- index 0000000000000000000000000000000000000000..b3be31553741937607a89be8b6a2ab1df208852e
134
- --- /dev/null
135
- +++ b/lib/grit/errors.rb
136
- @@ -0,0 +1,4 @@
137
- +class Grit
138
- + class InvalidGitRepositoryError < StandardError
139
- + end
140
- +end
141
-
142
- diff --git a/lib/grit/grit.rb b/lib/grit/grit.rb
143
- new file mode 100644
144
- index 0000000000000000000000000000000000000000..48fd36e16081ec09903f7a0e2253b3d16f9efb01
145
- --- /dev/null
146
- +++ b/lib/grit/grit.rb
147
- @@ -0,0 +1,24 @@
148
- +class Grit
149
- + attr_accessor :path
150
- +
151
- + # Create a new Grit instance
152
- + # +path+ is the path to either the root git directory or the bare git repo
153
- + #
154
- + # Examples
155
- + # g = Grit.new("/Users/tom/dev/grit")
156
- + # g = Grit.new("/Users/tom/public/grit.git")
157
- + def initialize(path)
158
- + if File.exist?(File.join(path, '.git'))
159
- + self.path = File.join(path, '.git')
160
- + elsif File.exist?(path) && path =~ /\.git$/
161
- + self.path = path
162
- + else
163
- + raise InvalidGitRepositoryError.new(path) unless File.exist?(path)
164
- + end
165
- + end
166
- +
167
- + # Return the project's description. Taken verbatim from REPO/description
168
- + def description
169
- + File.open(File.join(self.path, 'description')).read.chomp
170
- + end
171
- +end
172
-
173
- diff --git a/test/helper.rb b/test/helper.rb
174
- new file mode 100644
175
- index 0000000000000000000000000000000000000000..56e21da6b4ce3021d2754775dfa589947a4e37e5
176
- --- /dev/null
177
- +++ b/test/helper.rb
178
- @@ -0,0 +1,5 @@
179
- +require File.join(File.dirname(__FILE__), *%w[.. lib grit])
180
- +
181
- +require 'test/unit'
182
- +
183
- +GRIT_REPO = File.join(File.dirname(__FILE__), *%w[..])
184
- diff --git a/test/test_grit.rb b/test/test_grit.rb
185
- new file mode 100644
186
- index 0000000000000000000000000000000000000000..93aa481b37629797df739380306ae689e13f2855
187
- --- /dev/null
188
- +++ b/test/test_grit.rb
189
- @@ -0,0 +1,11 @@
190
- +require File.dirname(__FILE__) + '/helper'
191
- +
192
- +class TestGrit < Test::Unit::TestCase
193
- + def setup
194
- + @g = Grit.new(GRIT_REPO)
195
- + end
196
- +
197
- + def test_description
198
- + assert_equal "Grit is a ruby library for interfacing with git repositories.", @g.description
199
- + end
200
- +end
201
-