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
metadata.gz.sig
CHANGED
Binary file
|
data/vendor/grit/History.txt
DELETED
data/vendor/grit/Manifest.txt
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
Manifest.txt
|
3
|
-
README.txt
|
4
|
-
Rakefile
|
5
|
-
grit.gemspec
|
6
|
-
lib/grit.rb
|
7
|
-
lib/grit/actor.rb
|
8
|
-
lib/grit/blob.rb
|
9
|
-
lib/grit/commit.rb
|
10
|
-
lib/grit/config.rb
|
11
|
-
lib/grit/diff.rb
|
12
|
-
lib/grit/errors.rb
|
13
|
-
lib/grit/git.rb
|
14
|
-
lib/grit/lazy.rb
|
15
|
-
lib/grit/ref.rb
|
16
|
-
lib/grit/repo.rb
|
17
|
-
lib/grit/tree.rb
|
18
|
-
test/fixtures/blame
|
19
|
-
test/fixtures/cat_file_blob
|
20
|
-
test/fixtures/cat_file_blob_size
|
21
|
-
test/fixtures/diff_2
|
22
|
-
test/fixtures/diff_2f
|
23
|
-
test/fixtures/diff_f
|
24
|
-
test/fixtures/diff_i
|
25
|
-
test/fixtures/diff_mode_only
|
26
|
-
test/fixtures/diff_new_mode
|
27
|
-
test/fixtures/diff_p
|
28
|
-
test/fixtures/for_each_ref
|
29
|
-
test/fixtures/for_each_ref_remotes
|
30
|
-
test/fixtures/for_each_ref_tags
|
31
|
-
test/fixtures/ls_tree_a
|
32
|
-
test/fixtures/ls_tree_b
|
33
|
-
test/fixtures/ls_tree_commit
|
34
|
-
test/fixtures/rev_list
|
35
|
-
test/fixtures/rev_list_count
|
36
|
-
test/fixtures/rev_list_single
|
37
|
-
test/fixtures/rev_parse
|
38
|
-
test/fixtures/show_empty_commit
|
39
|
-
test/fixtures/simple_config
|
40
|
-
test/helper.rb
|
41
|
-
test/profile.rb
|
42
|
-
test/suite.rb
|
43
|
-
test/test_actor.rb
|
44
|
-
test/test_blob.rb
|
45
|
-
test/test_commit.rb
|
46
|
-
test/test_config.rb
|
47
|
-
test/test_diff.rb
|
48
|
-
test/test_git.rb
|
49
|
-
test/test_head.rb
|
50
|
-
test/test_reality.rb
|
51
|
-
test/test_repo.rb
|
52
|
-
test/test_tag.rb
|
53
|
-
test/test_tree.rb
|
data/vendor/grit/README.txt
DELETED
@@ -1,213 +0,0 @@
|
|
1
|
-
grit
|
2
|
-
by Tom Preston-Werner, Chris Wanstrath
|
3
|
-
http://github.com/mojombo/grit
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
Grit is a Ruby library for extracting information from a git repository in and
|
8
|
-
object oriented manner.
|
9
|
-
|
10
|
-
== REQUIREMENTS:
|
11
|
-
|
12
|
-
* git (http://git.or.cz) tested with 1.5.3.4
|
13
|
-
|
14
|
-
== INSTALL:
|
15
|
-
|
16
|
-
$ gem sources -a http://gems.github.com/ (you only need to do this once)
|
17
|
-
$ gem install mojombo-grit
|
18
|
-
|
19
|
-
== SOURCE:
|
20
|
-
|
21
|
-
Grit's git repo is available on GitHub, which can be browsed at:
|
22
|
-
|
23
|
-
http://github.com/mojombo/grit
|
24
|
-
|
25
|
-
and cloned from:
|
26
|
-
|
27
|
-
git://github.com/mojombo/grit.git
|
28
|
-
|
29
|
-
== USAGE:
|
30
|
-
|
31
|
-
Grit gives you object model access to your git repository. Once you have
|
32
|
-
created a repository object, you can traverse it to find parent commit(s),
|
33
|
-
trees, blobs, etc.
|
34
|
-
|
35
|
-
= Initialize a Repo object
|
36
|
-
|
37
|
-
The first step is to create a Grit::Repo object to represent your repo. I
|
38
|
-
include the Grit module so reduce typing.
|
39
|
-
|
40
|
-
require 'mojombo-grit'
|
41
|
-
include Grit
|
42
|
-
repo = Repo.new("/Users/tom/dev/grit")
|
43
|
-
|
44
|
-
In the above example, the directory /Users/tom/dev/grit is my working
|
45
|
-
repo and contains the .git directory. You can also initialize Grit with a
|
46
|
-
bare repo.
|
47
|
-
|
48
|
-
repo = Repo.new("/var/git/grit.git")
|
49
|
-
|
50
|
-
= Getting a list of commits
|
51
|
-
|
52
|
-
From the Repo object, you can get a list of commits as an array of Commit
|
53
|
-
objects.
|
54
|
-
|
55
|
-
repo.commits
|
56
|
-
# => [#<Grit::Commit "e80bbd2ce67651aa18e57fb0b43618ad4baf7750">,
|
57
|
-
#<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">,
|
58
|
-
#<Grit::Commit "038af8c329ef7c1bae4568b98bd5c58510465493">,
|
59
|
-
#<Grit::Commit "40d3057d09a7a4d61059bca9dca5ae698de58cbe">,
|
60
|
-
#<Grit::Commit "4ea50f4754937bf19461af58ce3b3d24c77311d9">]
|
61
|
-
|
62
|
-
Called without arguments, Repo#commits returns a list of up to ten commits
|
63
|
-
reachable by the master branch (starting at the latest commit). You can ask
|
64
|
-
for commits beginning at a different branch, commit, tag, etc.
|
65
|
-
|
66
|
-
repo.commits('mybranch')
|
67
|
-
repo.commits('40d3057d09a7a4d61059bca9dca5ae698de58cbe')
|
68
|
-
repo.commits('v0.1')
|
69
|
-
|
70
|
-
You can specify the maximum number of commits to return.
|
71
|
-
|
72
|
-
repo.commits('master', 100)
|
73
|
-
|
74
|
-
If you need paging, you can specify a number of commits to skip.
|
75
|
-
|
76
|
-
repo.commits('master', 10, 20)
|
77
|
-
|
78
|
-
The above will return commits 21-30 from the commit list.
|
79
|
-
|
80
|
-
= The Commit object
|
81
|
-
|
82
|
-
Commit objects contain information about that commit.
|
83
|
-
|
84
|
-
head = repo.commits.first
|
85
|
-
|
86
|
-
head.id
|
87
|
-
# => "e80bbd2ce67651aa18e57fb0b43618ad4baf7750"
|
88
|
-
|
89
|
-
head.parents
|
90
|
-
# => [#<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">]
|
91
|
-
|
92
|
-
head.tree
|
93
|
-
# => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
|
94
|
-
|
95
|
-
head.author
|
96
|
-
# => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
|
97
|
-
|
98
|
-
head.authored_date
|
99
|
-
# => Wed Oct 24 22:02:31 -0700 2007
|
100
|
-
|
101
|
-
head.committer
|
102
|
-
# => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
|
103
|
-
|
104
|
-
head.committed_date
|
105
|
-
# => Wed Oct 24 22:02:31 -0700 2007
|
106
|
-
|
107
|
-
head.message
|
108
|
-
# => "add Actor inspect"
|
109
|
-
|
110
|
-
You can traverse a commit's ancestry by chaining calls to #parents.
|
111
|
-
|
112
|
-
repo.commits.first.parents[0].parents[0].parents[0]
|
113
|
-
|
114
|
-
The above corresponds to master^^^ or master~3 in git parlance.
|
115
|
-
|
116
|
-
= The Tree object
|
117
|
-
|
118
|
-
A tree records pointers to the contents of a directory. Let's say you want
|
119
|
-
the root tree of the latest commit on the master branch.
|
120
|
-
|
121
|
-
tree = repo.commits.first.tree
|
122
|
-
# => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
|
123
|
-
|
124
|
-
tree.id
|
125
|
-
# => "3536eb9abac69c3e4db583ad38f3d30f8db4771f"
|
126
|
-
|
127
|
-
Once you have a tree, you can get the contents.
|
128
|
-
|
129
|
-
contents = tree.contents
|
130
|
-
# => [#<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">,
|
131
|
-
#<Grit::Blob "81d2c27608b352814cbe979a6acd678d30219678">,
|
132
|
-
#<Grit::Tree "c3d07b0083f01a6e1ac969a0f32b8d06f20c62e5">,
|
133
|
-
#<Grit::Tree "4d00fe177a8407dbbc64a24dbfc564762c0922d8">]
|
134
|
-
|
135
|
-
This tree contains two Blob objects and two Tree objects. The trees are
|
136
|
-
subdirectories and the blobs are files. Trees below the root have additional
|
137
|
-
attributes.
|
138
|
-
|
139
|
-
contents.last.name
|
140
|
-
# => "lib"
|
141
|
-
|
142
|
-
contents.last.mode
|
143
|
-
# => "040000"
|
144
|
-
|
145
|
-
There is a convenience method that allows you to get a named sub-object
|
146
|
-
from a tree.
|
147
|
-
|
148
|
-
tree/"lib"
|
149
|
-
# => #<Grit::Tree "e74893a3d8a25cbb1367cf241cc741bfd503c4b2">
|
150
|
-
|
151
|
-
You can also get a tree directly from the repo if you know its name.
|
152
|
-
|
153
|
-
repo.tree
|
154
|
-
# => #<Grit::Tree "master">
|
155
|
-
|
156
|
-
repo.tree("91169e1f5fa4de2eaea3f176461f5dc784796769")
|
157
|
-
# => #<Grit::Tree "91169e1f5fa4de2eaea3f176461f5dc784796769">
|
158
|
-
|
159
|
-
= The Blob object
|
160
|
-
|
161
|
-
A blob represents a file. Trees often contain blobs.
|
162
|
-
|
163
|
-
blob = tree.contents.first
|
164
|
-
# => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
|
165
|
-
|
166
|
-
A blob has certain attributes.
|
167
|
-
|
168
|
-
blob.id
|
169
|
-
# => "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666"
|
170
|
-
|
171
|
-
blob.name
|
172
|
-
# => "README.txt"
|
173
|
-
|
174
|
-
blob.mode
|
175
|
-
# => "100644"
|
176
|
-
|
177
|
-
blob.size
|
178
|
-
# => 7726
|
179
|
-
|
180
|
-
You can get the data of a blob as a string.
|
181
|
-
|
182
|
-
blob.data
|
183
|
-
# => "Grit is a library to ..."
|
184
|
-
|
185
|
-
You can also get a blob directly from the repo if you know its name.
|
186
|
-
|
187
|
-
repo.blob("4ebc8aea50e0a67e000ba29a30809d0a7b9b2666")
|
188
|
-
# => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
|
189
|
-
|
190
|
-
== LICENSE:
|
191
|
-
|
192
|
-
(The MIT License)
|
193
|
-
|
194
|
-
Copyright (c) 2007 Tom Preston-Werner
|
195
|
-
|
196
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
197
|
-
a copy of this software and associated documentation files (the
|
198
|
-
'Software'), to deal in the Software without restriction, including
|
199
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
200
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
201
|
-
permit persons to whom the Software is furnished to do so, subject to
|
202
|
-
the following conditions:
|
203
|
-
|
204
|
-
The above copyright notice and this permission notice shall be
|
205
|
-
included in all copies or substantial portions of the Software.
|
206
|
-
|
207
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
208
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
209
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
210
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
211
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
212
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
213
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/vendor/grit/Rakefile
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'hoe'
|
3
|
-
require './lib/grit.rb'
|
4
|
-
|
5
|
-
Hoe.new('grit', Grit::VERSION) do |p|
|
6
|
-
p.author = 'Tom Preston-Werner'
|
7
|
-
p.email = 'tom@rubyisawesome.com'
|
8
|
-
p.summary = 'Object model interface to a git repo'
|
9
|
-
p.description = p.paragraphs_of('README.txt', 2..2).join("\n\n")
|
10
|
-
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[2..-1].map { |u| u.strip }
|
11
|
-
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
12
|
-
p.extra_deps << ['mime-types']
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Open an irb session preloaded with this library"
|
16
|
-
task :console do
|
17
|
-
sh "irb -rubygems -r ./lib/grit.rb"
|
18
|
-
end
|
19
|
-
|
20
|
-
task :coverage do
|
21
|
-
system("rm -fr coverage")
|
22
|
-
system("rcov test/test_*.rb")
|
23
|
-
system("open coverage/index.html")
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "Upload site to Rubyforge"
|
27
|
-
task :site do
|
28
|
-
sh "scp -r doc/* mojombo@grit.rubyforge.org:/var/www/gforge-projects/grit"
|
29
|
-
end
|
data/vendor/grit/grit.gemspec
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = "grit"
|
3
|
-
s.version = "0.8.1"
|
4
|
-
s.date = "2008-04-24"
|
5
|
-
s.summary = "Object model interface to a git repo"
|
6
|
-
s.email = "tom@rubyisawesome.com"
|
7
|
-
s.homepage = "http://github.com/mojombo/grit"
|
8
|
-
s.description = "Grit is a Ruby library for extracting information from a git repository in and object oriented manner."
|
9
|
-
s.has_rdoc = true
|
10
|
-
s.authors = ["Tom Preston-Werner"]
|
11
|
-
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "grit.gemspec", "lib/grit.rb", "lib/grit/actor.rb", "lib/grit/blob.rb", "lib/grit/commit.rb", "lib/grit/config.rb", "lib/grit/diff.rb", "lib/grit/errors.rb", "lib/grit/git.rb", "lib/grit/head.rb", "lib/grit/lazy.rb", "lib/grit/repo.rb", "lib/grit/tag.rb", "lib/grit/tree.rb", "test/fixtures/blame", "test/fixtures/cat_file_blob", "test/fixtures/cat_file_blob_size", "test/fixtures/diff_2", "test/fixtures/diff_2f", "test/fixtures/diff_f", "test/fixtures/diff_i", "test/fixtures/diff_mode_only", "test/fixtures/diff_new_mode", "test/fixtures/diff_p", "test/fixtures/for_each_ref", "test/fixtures/for_each_ref_tags", "test/fixtures/ls_tree_a", "test/fixtures/ls_tree_b", "test/fixtures/ls_tree_commit", "test/fixtures/rev_list", "test/fixtures/rev_list_count", "test/fixtures/rev_list_single", "test/fixtures/rev_parse", "test/fixtures/show_empty_commit", "test/fixtures/simple_config", "test/helper.rb", "test/profile.rb", "test/suite.rb", "test/test_actor.rb", "test/test_blob.rb", "test/test_commit.rb", "test/test_config.rb", "test/test_diff.rb", "test/test_git.rb", "test/test_head.rb", "test/test_reality.rb", "test/test_repo.rb", "test/test_tag.rb", "test/test_tree.rb", "test/test_real.rb"]
|
12
|
-
s.test_files = ["test/test_actor.rb", "test/test_blob.rb", "test/test_commit.rb", "test/test_config.rb", "test/test_diff.rb", "test/test_git.rb", "test/test_head.rb", "test/test_real.rb", "test/test_reality.rb", "test/test_repo.rb", "test/test_tag.rb", "test/test_tree.rb"]
|
13
|
-
s.rdoc_options = ["--main", "README.txt"]
|
14
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
15
|
-
s.add_dependency("mime-types", ["> 0.0.0"])
|
16
|
-
end
|
data/vendor/grit/lib/grit.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
2
|
-
|
3
|
-
# core
|
4
|
-
require 'fileutils'
|
5
|
-
require 'time'
|
6
|
-
|
7
|
-
# stdlib
|
8
|
-
require 'timeout'
|
9
|
-
|
10
|
-
# third party
|
11
|
-
require 'rubygems'
|
12
|
-
require 'mime/types'
|
13
|
-
require 'open4'
|
14
|
-
|
15
|
-
# internal requires
|
16
|
-
require 'grit/lazy'
|
17
|
-
require 'grit/errors'
|
18
|
-
require 'grit/git'
|
19
|
-
require 'grit/ref'
|
20
|
-
require 'grit/commit'
|
21
|
-
require 'grit/tree'
|
22
|
-
require 'grit/blob'
|
23
|
-
require 'grit/actor'
|
24
|
-
require 'grit/diff'
|
25
|
-
require 'grit/config'
|
26
|
-
require 'grit/repo'
|
27
|
-
require 'grit/index'
|
28
|
-
|
29
|
-
module Grit
|
30
|
-
class << self
|
31
|
-
attr_accessor :debug
|
32
|
-
end
|
33
|
-
|
34
|
-
self.debug = false
|
35
|
-
|
36
|
-
VERSION = '0.8.1'
|
37
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Grit
|
2
|
-
|
3
|
-
class Actor
|
4
|
-
attr_reader :name
|
5
|
-
attr_reader :email
|
6
|
-
|
7
|
-
def initialize(name, email)
|
8
|
-
@name = name
|
9
|
-
@email = email
|
10
|
-
end
|
11
|
-
alias_method :to_s, :name
|
12
|
-
|
13
|
-
# Create an Actor from a string.
|
14
|
-
# +str+ is the string, which is expected to be in regular git format
|
15
|
-
#
|
16
|
-
# Format
|
17
|
-
# John Doe <jdoe@example.com>
|
18
|
-
#
|
19
|
-
# Returns Actor
|
20
|
-
def self.from_string(str)
|
21
|
-
case str
|
22
|
-
when /<.+>/
|
23
|
-
m, name, email = *str.match(/(.*) <(.+?)>/)
|
24
|
-
return self.new(name, email)
|
25
|
-
else
|
26
|
-
return self.new(str, nil)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Pretty object inspection
|
31
|
-
def inspect
|
32
|
-
%Q{#<Grit::Actor "#{@name} <#{@email}>">}
|
33
|
-
end
|
34
|
-
end # Actor
|
35
|
-
|
36
|
-
end # Grit
|
@@ -1,117 +0,0 @@
|
|
1
|
-
module Grit
|
2
|
-
|
3
|
-
class Blob
|
4
|
-
DEFAULT_MIME_TYPE = "text/plain"
|
5
|
-
|
6
|
-
attr_reader :id
|
7
|
-
attr_reader :mode
|
8
|
-
attr_reader :name
|
9
|
-
|
10
|
-
# Create an unbaked Blob containing just the specified attributes
|
11
|
-
# +repo+ is the Repo
|
12
|
-
# +atts+ is a Hash of instance variable data
|
13
|
-
#
|
14
|
-
# Returns Grit::Blob (unbaked)
|
15
|
-
def self.create(repo, atts)
|
16
|
-
self.allocate.create_initialize(repo, atts)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Initializer for Blob.create
|
20
|
-
# +repo+ is the Repo
|
21
|
-
# +atts+ is a Hash of instance variable data
|
22
|
-
#
|
23
|
-
# Returns Grit::Blob (unbaked)
|
24
|
-
def create_initialize(repo, atts)
|
25
|
-
@repo = repo
|
26
|
-
atts.each do |k, v|
|
27
|
-
instance_variable_set("@#{k}".to_sym, v)
|
28
|
-
end
|
29
|
-
self
|
30
|
-
end
|
31
|
-
|
32
|
-
# The size of this blob in bytes
|
33
|
-
#
|
34
|
-
# Returns Integer
|
35
|
-
def size
|
36
|
-
@size ||= @repo.git.cat_file({:s => true}, id).chomp.to_i
|
37
|
-
end
|
38
|
-
|
39
|
-
# The binary contents of this blob.
|
40
|
-
#
|
41
|
-
# Returns String
|
42
|
-
def data
|
43
|
-
@data ||= @repo.git.cat_file({:p => true}, id)
|
44
|
-
end
|
45
|
-
|
46
|
-
# The mime type of this file (based on the filename)
|
47
|
-
#
|
48
|
-
# Returns String
|
49
|
-
def mime_type
|
50
|
-
guesses = MIME::Types.type_for(self.name) rescue []
|
51
|
-
guesses.first ? guesses.first.simplified : DEFAULT_MIME_TYPE
|
52
|
-
end
|
53
|
-
|
54
|
-
# The blame information for the given file at the given commit
|
55
|
-
#
|
56
|
-
# Returns Array: [Grit::Commit, Array: [<line>]]
|
57
|
-
def self.blame(repo, commit, file)
|
58
|
-
data = repo.git.blame({:p => true}, commit, '--', file)
|
59
|
-
|
60
|
-
commits = {}
|
61
|
-
blames = []
|
62
|
-
info = nil
|
63
|
-
|
64
|
-
data.split("\n").each do |line|
|
65
|
-
parts = line.split(/\s+/, 2)
|
66
|
-
case parts.first
|
67
|
-
when /^[0-9A-Fa-f]{40}$/
|
68
|
-
case line
|
69
|
-
when /^([0-9A-Fa-f]{40}) (\d+) (\d+) (\d+)$/
|
70
|
-
_, id, origin_line, final_line, group_lines = *line.match(/^([0-9A-Fa-f]{40}) (\d+) (\d+) (\d+)$/)
|
71
|
-
info = {:id => id}
|
72
|
-
blames << [nil, []]
|
73
|
-
when /^([0-9A-Fa-f]{40}) (\d+) (\d+)$/
|
74
|
-
_, id, origin_line, final_line = *line.match(/^([0-9A-Fa-f]{40}) (\d+) (\d+)$/)
|
75
|
-
info = {:id => id}
|
76
|
-
end
|
77
|
-
when /^(author|committer)/
|
78
|
-
case parts.first
|
79
|
-
when /^(.+)-mail$/
|
80
|
-
info["#{$1}_email".intern] = parts.last
|
81
|
-
when /^(.+)-time$/
|
82
|
-
info["#{$1}_date".intern] = Time.at(parts.last.to_i)
|
83
|
-
when /^(author|committer)$/
|
84
|
-
info[$1.intern] = parts.last
|
85
|
-
end
|
86
|
-
when /^filename/
|
87
|
-
info[:filename] = parts.last
|
88
|
-
when /^summary/
|
89
|
-
info[:summary] = parts.last
|
90
|
-
when ''
|
91
|
-
c = commits[info[:id]]
|
92
|
-
unless c
|
93
|
-
c = Commit.create(repo, :id => info[:id],
|
94
|
-
:author => Actor.from_string(info[:author] + ' ' + info[:author_email]),
|
95
|
-
:authored_date => info[:author_date],
|
96
|
-
:committer => Actor.from_string(info[:committer] + ' ' + info[:committer_email]),
|
97
|
-
:committed_date => info[:committer_date],
|
98
|
-
:message => info[:summary])
|
99
|
-
commits[info[:id]] = c
|
100
|
-
end
|
101
|
-
_, text = *line.match(/^\t(.*)$/)
|
102
|
-
blames.last[0] = c
|
103
|
-
blames.last[1] << text
|
104
|
-
info = nil
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
blames
|
109
|
-
end
|
110
|
-
|
111
|
-
# Pretty object inspection
|
112
|
-
def inspect
|
113
|
-
%Q{#<Grit::Blob "#{@id}">}
|
114
|
-
end
|
115
|
-
end # Blob
|
116
|
-
|
117
|
-
end # Grit
|