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.
- data.tar.gz.sig +2 -1
- data/History.txt +4 -0
- data/Manifest.txt +3 -56
- data/bin/git-trip +3 -0
- data/git-trip.gemspec +36 -0
- data/lib/git-trip.rb +3 -5
- data/lib/git-trip/errors.rb +1 -0
- data/lib/git-trip/gitter.rb +1 -0
- data/lib/git-trip/gitter/github.rb +68 -0
- data/lib/git-trip/gitter/uri.rb +27 -0
- data/spec/git-trip/errors_spec.rb +4 -0
- data/spec/git-trip/gitter/github_spec.rb +30 -0
- data/spec/git-trip/gitter/uri_spec.rb +4 -1
- data/spec/git-trip/gitter_spec.rb +8 -0
- metadata +5 -61
- metadata.gz.sig +0 -0
- data/vendor/grit/History.txt +0 -6
- data/vendor/grit/Manifest.txt +0 -53
- data/vendor/grit/README.txt +0 -213
- data/vendor/grit/Rakefile +0 -29
- data/vendor/grit/grit.gemspec +0 -16
- data/vendor/grit/lib/grit.rb +0 -37
- data/vendor/grit/lib/grit/actor.rb +0 -36
- data/vendor/grit/lib/grit/blob.rb +0 -117
- data/vendor/grit/lib/grit/commit.rb +0 -208
- data/vendor/grit/lib/grit/config.rb +0 -44
- data/vendor/grit/lib/grit/diff.rb +0 -70
- data/vendor/grit/lib/grit/errors.rb +0 -7
- data/vendor/grit/lib/grit/git.rb +0 -116
- data/vendor/grit/lib/grit/index.rb +0 -77
- data/vendor/grit/lib/grit/lazy.rb +0 -31
- data/vendor/grit/lib/grit/ref.rb +0 -110
- data/vendor/grit/lib/grit/repo.rb +0 -318
- data/vendor/grit/lib/grit/tree.rb +0 -99
- data/vendor/grit/test/fixtures/blame +0 -131
- data/vendor/grit/test/fixtures/cat_file_blob +0 -1
- data/vendor/grit/test/fixtures/cat_file_blob_size +0 -1
- data/vendor/grit/test/fixtures/diff_2 +0 -54
- data/vendor/grit/test/fixtures/diff_2f +0 -19
- data/vendor/grit/test/fixtures/diff_f +0 -15
- data/vendor/grit/test/fixtures/diff_i +0 -201
- data/vendor/grit/test/fixtures/diff_mode_only +0 -1152
- data/vendor/grit/test/fixtures/diff_new_mode +0 -17
- data/vendor/grit/test/fixtures/diff_p +0 -610
- data/vendor/grit/test/fixtures/for_each_ref +0 -0
- data/vendor/grit/test/fixtures/for_each_ref_remotes +0 -0
- data/vendor/grit/test/fixtures/for_each_ref_tags +0 -0
- data/vendor/grit/test/fixtures/ls_tree_a +0 -7
- data/vendor/grit/test/fixtures/ls_tree_b +0 -2
- data/vendor/grit/test/fixtures/ls_tree_commit +0 -3
- data/vendor/grit/test/fixtures/rev_list +0 -26
- data/vendor/grit/test/fixtures/rev_list_count +0 -655
- data/vendor/grit/test/fixtures/rev_list_single +0 -7
- data/vendor/grit/test/fixtures/rev_parse +0 -1
- data/vendor/grit/test/fixtures/show_empty_commit +0 -6
- data/vendor/grit/test/fixtures/simple_config +0 -2
- data/vendor/grit/test/helper.rb +0 -17
- data/vendor/grit/test/profile.rb +0 -21
- data/vendor/grit/test/suite.rb +0 -6
- data/vendor/grit/test/test_actor.rb +0 -35
- data/vendor/grit/test/test_blob.rb +0 -74
- data/vendor/grit/test/test_commit.rb +0 -182
- data/vendor/grit/test/test_config.rb +0 -58
- data/vendor/grit/test/test_diff.rb +0 -18
- data/vendor/grit/test/test_git.rb +0 -52
- data/vendor/grit/test/test_head.rb +0 -22
- data/vendor/grit/test/test_real.rb +0 -19
- data/vendor/grit/test/test_reality.rb +0 -17
- data/vendor/grit/test/test_remote.rb +0 -15
- data/vendor/grit/test/test_repo.rb +0 -278
- data/vendor/grit/test/test_tag.rb +0 -29
- data/vendor/grit/test/test_tree.rb +0 -91
@@ -1,99 +0,0 @@
|
|
1
|
-
module Grit
|
2
|
-
|
3
|
-
class Tree
|
4
|
-
lazy_reader :contents
|
5
|
-
attr_reader :id
|
6
|
-
attr_reader :mode
|
7
|
-
attr_reader :name
|
8
|
-
|
9
|
-
# Construct the contents of the tree
|
10
|
-
# +repo+ is the Repo
|
11
|
-
# +treeish+ is the reference
|
12
|
-
# +paths+ is an optional Array of directory paths to restrict the tree
|
13
|
-
#
|
14
|
-
# Returns Grit::Tree (baked)
|
15
|
-
def self.construct(repo, treeish, paths = [])
|
16
|
-
output = repo.git.ls_tree({}, treeish, *paths)
|
17
|
-
|
18
|
-
self.allocate.construct_initialize(repo, treeish, output)
|
19
|
-
end
|
20
|
-
|
21
|
-
def construct_initialize(repo, id, text)
|
22
|
-
@repo = repo
|
23
|
-
@id = id
|
24
|
-
@contents = []
|
25
|
-
|
26
|
-
text.split("\n").each do |line|
|
27
|
-
@contents << content_from_string(repo, line)
|
28
|
-
end
|
29
|
-
@contents.compact!
|
30
|
-
|
31
|
-
self
|
32
|
-
end
|
33
|
-
|
34
|
-
def lazy_source
|
35
|
-
Tree.construct(@repo, @id, [])
|
36
|
-
end
|
37
|
-
|
38
|
-
# Create an unbaked Tree containing just the specified attributes
|
39
|
-
# +repo+ is the Repo
|
40
|
-
# +atts+ is a Hash of instance variable data
|
41
|
-
#
|
42
|
-
# Returns Grit::Tree (unbaked)
|
43
|
-
def self.create(repo, atts)
|
44
|
-
self.allocate.create_initialize(repo, atts)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Initializer for Tree.create
|
48
|
-
# +repo+ is the Repo
|
49
|
-
# +atts+ is a Hash of instance variable data
|
50
|
-
#
|
51
|
-
# Returns Grit::Tree (unbaked)
|
52
|
-
def create_initialize(repo, atts)
|
53
|
-
@repo = repo
|
54
|
-
|
55
|
-
atts.each do |k, v|
|
56
|
-
instance_variable_set("@#{k}", v)
|
57
|
-
end
|
58
|
-
self
|
59
|
-
end
|
60
|
-
|
61
|
-
# Parse a content item and create the appropriate object
|
62
|
-
# +repo+ is the Repo
|
63
|
-
# +text+ is the single line containing the items data in `git ls-tree` format
|
64
|
-
#
|
65
|
-
# Returns Grit::Blob or Grit::Tree
|
66
|
-
def content_from_string(repo, text)
|
67
|
-
mode, type, id, name = text.split(" ", 4)
|
68
|
-
case type
|
69
|
-
when "tree"
|
70
|
-
Tree.create(repo, :id => id, :mode => mode, :name => name)
|
71
|
-
when "blob"
|
72
|
-
Blob.create(repo, :id => id, :mode => mode, :name => name)
|
73
|
-
when "commit"
|
74
|
-
nil
|
75
|
-
else
|
76
|
-
raise "Invalid type: #{type}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# Find the named object in this tree's contents
|
81
|
-
#
|
82
|
-
# Examples
|
83
|
-
# Repo.new('/path/to/grit').tree/'lib'
|
84
|
-
# # => #<Grit::Tree "6cc23ee138be09ff8c28b07162720018b244e95e">
|
85
|
-
# Repo.new('/path/to/grit').tree/'README.txt'
|
86
|
-
# # => #<Grit::Blob "8b1e02c0fb554eed2ce2ef737a68bb369d7527df">
|
87
|
-
#
|
88
|
-
# Returns Grit::Blob or Grit::Tree or nil if not found
|
89
|
-
def /(file)
|
90
|
-
self.contents.select { |c| c.name == file }.first
|
91
|
-
end
|
92
|
-
|
93
|
-
# Pretty object inspection
|
94
|
-
def inspect
|
95
|
-
%Q{#<Grit::Tree "#{@id}">}
|
96
|
-
end
|
97
|
-
end # Tree
|
98
|
-
|
99
|
-
end # Grit
|
@@ -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
|
@@ -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)
|
@@ -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
|
-
|
@@ -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
|
-
|