schacon-grit 0.9.3 → 0.9.4
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.
- data/Manifest.txt +1 -0
- data/README.txt +3 -3
- data/grit.gemspec +6 -6
- data/lib/grit.rb +9 -3
- data/lib/grit/commit.rb +1 -1
- data/lib/grit/git-ruby.rb +7 -3
- data/lib/grit/git-ruby/file_index.rb +10 -3
- data/lib/grit/git-ruby/internal/loose.rb +2 -1
- data/lib/grit/git-ruby/repository.rb +2 -0
- data/lib/grit/git.rb +27 -30
- data/lib/grit/index.rb +3 -1
- data/lib/grit/lazy.rb +4 -2
- data/lib/grit/submodule.rb +84 -0
- data/lib/grit/tree.rb +6 -2
- data/lib/open3_detach.rb +46 -0
- data/test/test_commit.rb +6 -0
- data/test/test_git.rb +5 -11
- data/test/test_repo.rb +8 -0
- data/test/test_tag.rb +3 -3
- data/test/test_tree.rb +5 -5
- metadata +6 -5
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
grit
|
2
|
-
by Tom Preston-Werner,
|
2
|
+
by Tom Preston-Werner, Scott Chacon
|
3
3
|
http://github.com/mojombo/grit
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
Grit is a Ruby library for extracting information from a git repository in
|
7
|
+
Grit is a Ruby library for extracting information from a git repository in an
|
8
8
|
object oriented manner.
|
9
9
|
|
10
10
|
== REQUIREMENTS:
|
11
11
|
|
12
|
-
* git (http://git.
|
12
|
+
* git (http://git-scm.com) tested with 1.6.0.2
|
13
13
|
|
14
14
|
== INSTALL:
|
15
15
|
|
data/grit.gemspec
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "grit"
|
3
|
-
s.version = "0.9.
|
4
|
-
s.date = "2008-
|
3
|
+
s.version = "0.9.4"
|
4
|
+
s.date = "2008-11-07"
|
5
5
|
s.summary = "Object model interface to a git repo"
|
6
6
|
s.email = "tom@rubyisawesome.com"
|
7
|
-
s.homepage = "http://github.com/
|
7
|
+
s.homepage = "http://github.com/mojombo/grit"
|
8
8
|
s.description = "Grit is a Ruby library for extracting information from a git repository in and object oriented manner."
|
9
9
|
s.has_rdoc = true
|
10
10
|
s.authors = ["Tom Preston-Werner", "Scott Chacon"]
|
11
11
|
s.files = ["History.txt",
|
12
|
-
"Manifest.txt",
|
13
12
|
"README.txt",
|
14
13
|
"Rakefile",
|
15
14
|
"grit.gemspec",
|
@@ -23,7 +22,6 @@ Gem::Specification.new do |s|
|
|
23
22
|
"lib/grit/git-ruby/commit_db.rb",
|
24
23
|
"lib/grit/git-ruby/file_index.rb",
|
25
24
|
"lib/grit/git-ruby/git_object.rb",
|
26
|
-
"lib/grit/git-ruby/internal",
|
27
25
|
"lib/grit/git-ruby/internal/loose.rb",
|
28
26
|
"lib/grit/git-ruby/internal/mmap.rb",
|
29
27
|
"lib/grit/git-ruby/internal/pack.rb",
|
@@ -38,9 +36,11 @@ Gem::Specification.new do |s|
|
|
38
36
|
"lib/grit/ref.rb",
|
39
37
|
"lib/grit/repo.rb",
|
40
38
|
"lib/grit/status.rb",
|
39
|
+
"lib/grit/submodule.rb",
|
41
40
|
"lib/grit/tag.rb",
|
42
41
|
"lib/grit/tree.rb",
|
43
|
-
"lib/grit.rb"
|
42
|
+
"lib/grit.rb",
|
43
|
+
"lib/open3_detach.rb"]
|
44
44
|
s.test_files = ["test/test_actor.rb",
|
45
45
|
"test/test_blob.rb", "test/test_commit.rb",
|
46
46
|
"test/test_config.rb",
|
data/lib/grit.rb
CHANGED
@@ -7,12 +7,17 @@ require 'time'
|
|
7
7
|
# stdlib
|
8
8
|
require 'timeout'
|
9
9
|
require 'logger'
|
10
|
+
require 'digest/sha1'
|
11
|
+
|
12
|
+
if defined? RUBY_ENGINE && RUBY_ENGINE == 'jruby'
|
13
|
+
require 'open3'
|
14
|
+
else
|
15
|
+
require 'open3_detach'
|
16
|
+
end
|
10
17
|
|
11
18
|
# third party
|
12
19
|
require 'rubygems'
|
13
20
|
require 'mime/types'
|
14
|
-
require 'open4'
|
15
|
-
require 'digest/sha1'
|
16
21
|
|
17
22
|
# internal requires
|
18
23
|
require 'grit/lazy'
|
@@ -30,6 +35,7 @@ require 'grit/config'
|
|
30
35
|
require 'grit/repo'
|
31
36
|
require 'grit/index'
|
32
37
|
require 'grit/status'
|
38
|
+
require 'grit/submodule'
|
33
39
|
|
34
40
|
|
35
41
|
module Grit
|
@@ -49,5 +55,5 @@ module Grit
|
|
49
55
|
|
50
56
|
@logger ||= ::Logger.new(STDOUT)
|
51
57
|
|
52
|
-
VERSION = '0.9.
|
58
|
+
VERSION = '0.9.4'
|
53
59
|
end
|
data/lib/grit/commit.rb
CHANGED
data/lib/grit/git-ruby.rb
CHANGED
@@ -51,7 +51,7 @@ module Grit
|
|
51
51
|
elsif (options.size == 0)
|
52
52
|
# pure rev-list
|
53
53
|
begin
|
54
|
-
return file_index.commits_from(rev_parse({}, ref)).join("\n")
|
54
|
+
return file_index.commits_from(rev_parse({}, ref)).join("\n") + "\n"
|
55
55
|
rescue
|
56
56
|
return method_missing('rev-list', options, ref)
|
57
57
|
end
|
@@ -65,7 +65,9 @@ module Grit
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def rev_parse(options, string)
|
68
|
+
def rev_parse(options, string)
|
69
|
+
raise RuntimeError, "invalid string: #{string}" unless string.is_a?(String)
|
70
|
+
|
69
71
|
if string =~ /\.\./
|
70
72
|
(sha1, sha2) = string.split('..')
|
71
73
|
return [rev_parse({}, sha1), rev_parse({}, sha2)]
|
@@ -89,7 +91,7 @@ module Grit
|
|
89
91
|
if File.file?(packref)
|
90
92
|
File.readlines(packref).each do |line|
|
91
93
|
if m = /^(\w{40}) refs\/.+?\/(.*?)$/.match(line)
|
92
|
-
next if !Regexp.new(string + '$').match(m[3])
|
94
|
+
next if !Regexp.new(Regexp.escape(string) + '$').match(m[3])
|
93
95
|
return m[1].chomp
|
94
96
|
end
|
95
97
|
end
|
@@ -111,6 +113,8 @@ module Grit
|
|
111
113
|
|
112
114
|
def blame_tree(commit, path = nil)
|
113
115
|
begin
|
116
|
+
path = path.to_a.join('/').to_s + '/' if (path && path != '')
|
117
|
+
path = '' if !path.is_a? String
|
114
118
|
commits = file_index.last_commits(rev_parse({}, commit), looking_for(commit, path))
|
115
119
|
clean_paths(commits)
|
116
120
|
rescue FileIndex::IndexFileNotFound
|
@@ -22,12 +22,18 @@ module Grit
|
|
22
22
|
class UnsupportedRef < StandardError
|
23
23
|
end
|
24
24
|
|
25
|
+
class << self
|
26
|
+
attr_accessor :max_file_size
|
27
|
+
end
|
28
|
+
|
29
|
+
self.max_file_size = 10_000_000 # ~10M
|
30
|
+
|
25
31
|
attr_reader :files
|
26
32
|
|
27
33
|
# initializes index given repo_path
|
28
34
|
def initialize(repo_path)
|
29
35
|
@index_file = File.join(repo_path, 'file-index')
|
30
|
-
if File.file?(@index_file)
|
36
|
+
if File.file?(@index_file) && (File.size(@index_file) < Grit::GitRuby::FileIndex.max_file_size)
|
31
37
|
read_index
|
32
38
|
else
|
33
39
|
raise IndexFileNotFound
|
@@ -46,6 +52,7 @@ module Grit
|
|
46
52
|
commits_from(commit_sha).size
|
47
53
|
end
|
48
54
|
|
55
|
+
# builds a list of all commits reachable from a single commit
|
49
56
|
def commits_from(commit_sha)
|
50
57
|
raise UnsupportedRef if commit_sha.is_a? Array
|
51
58
|
|
@@ -69,7 +76,7 @@ module Grit
|
|
69
76
|
end
|
70
77
|
|
71
78
|
def sort_commits(sha_array)
|
72
|
-
sha_array.sort { |a, b| @commit_order[b] <=> @commit_order[a] }
|
79
|
+
sha_array.sort { |a, b| @commit_order[b].to_i <=> @commit_order[a].to_i }
|
73
80
|
end
|
74
81
|
|
75
82
|
# returns files changed at commit sha
|
@@ -183,4 +190,4 @@ if __FILE__ == $0
|
|
183
190
|
end
|
184
191
|
|
185
192
|
|
186
|
-
|
193
|
+
|
@@ -27,7 +27,8 @@ module Grit
|
|
27
27
|
def [](sha1)
|
28
28
|
sha1 = sha1.unpack("H*")[0]
|
29
29
|
begin
|
30
|
-
|
30
|
+
return nil unless sha1[0...2] && sha1[2..39]
|
31
|
+
path = @directory + '/' + sha1[0...2] + '/' + sha1[2..39]
|
31
32
|
get_raw_object(File.read(path))
|
32
33
|
rescue Errno::ENOENT
|
33
34
|
nil
|
data/lib/grit/git.rb
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
trap("CHLD") do
|
2
|
-
begin
|
3
|
-
Process.wait(-1, Process::WNOHANG)
|
4
|
-
rescue Object
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
1
|
module Grit
|
9
2
|
|
10
3
|
class Git
|
@@ -26,7 +19,7 @@ module Grit
|
|
26
19
|
end
|
27
20
|
|
28
21
|
self.git_binary = "/usr/bin/env git"
|
29
|
-
self.git_timeout =
|
22
|
+
self.git_timeout = 10
|
30
23
|
|
31
24
|
attr_accessor :git_dir, :bytes_read
|
32
25
|
|
@@ -54,7 +47,7 @@ module Grit
|
|
54
47
|
timeout = true if timeout.nil?
|
55
48
|
|
56
49
|
opt_args = transform_options(options)
|
57
|
-
ext_args = args.map { |a| a == '--' ? a : "'#{a}'" }
|
50
|
+
ext_args = args.reject { |a| a.empty? }.map { |a| (a == '--' || a[0].chr == '|') ? a : "'#{a}'" }
|
58
51
|
|
59
52
|
call = "#{prefix}#{Git.git_binary} --git-dir='#{self.git_dir}' #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}#{postfix}"
|
60
53
|
Grit.log(call) if Grit.debug
|
@@ -65,37 +58,41 @@ module Grit
|
|
65
58
|
end
|
66
59
|
|
67
60
|
def sh(command)
|
68
|
-
ret,
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
61
|
+
ret, err = '', ''
|
62
|
+
Open3.popen3(command) do |_, stdout, stderr|
|
63
|
+
Timeout.timeout(self.class.git_timeout) do
|
64
|
+
while tmp = stdout.read(1024)
|
65
|
+
ret += tmp
|
66
|
+
if (@bytes_read += tmp.size) > 5242880 # 5.megabytes
|
67
|
+
bytes = @bytes_read
|
68
|
+
@bytes_read = 0
|
69
|
+
raise GitTimeout.new(command, bytes)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
@bytes_read = 0
|
78
|
-
raise GitTimeout.new(command, bytes)
|
74
|
+
while tmp = stderr.read(1024)
|
75
|
+
err += tmp
|
79
76
|
end
|
80
77
|
end
|
81
78
|
[ret, err]
|
82
|
-
rescue
|
83
|
-
[ret, err]
|
84
|
-
rescue Object => e
|
85
|
-
Process.kill('KILL', pid) rescue nil
|
79
|
+
rescue Timeout::Error, Grit::Git::GitTimeout
|
86
80
|
bytes = @bytes_read
|
87
81
|
@bytes_read = 0
|
88
82
|
raise GitTimeout.new(command, bytes)
|
89
83
|
end
|
90
84
|
|
91
85
|
def wild_sh(command)
|
92
|
-
ret, err =
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
86
|
+
ret, err = '', ''
|
87
|
+
Open3.popen3(command) do |_, stdout, stderr|
|
88
|
+
while tmp = stdout.read(1024)
|
89
|
+
ret += tmp
|
90
|
+
end
|
91
|
+
|
92
|
+
while tmp = stderr.read(1024)
|
93
|
+
err += tmp
|
94
|
+
end
|
95
|
+
end
|
99
96
|
[ret, err]
|
100
97
|
end
|
101
98
|
|
data/lib/grit/index.rb
CHANGED
@@ -65,7 +65,9 @@ module Grit
|
|
65
65
|
commit_sha1 = self.repo.git.ruby_git.put_raw_object(contents.join("\n"), 'commit')
|
66
66
|
|
67
67
|
# self.repo.git.update_ref({}, 'HEAD', commit_sha1)
|
68
|
-
File.
|
68
|
+
ref_heads = File.join(self.repo.path, 'refs', 'heads')
|
69
|
+
FileUtils.mkdir_p(ref_heads)
|
70
|
+
File.open(File.join(ref_heads, head), 'w') do |f|
|
69
71
|
f.write(commit_sha1)
|
70
72
|
end if commit_sha1
|
71
73
|
|
data/lib/grit/lazy.rb
CHANGED
@@ -20,8 +20,10 @@ module Lazy
|
|
20
20
|
args.each do |arg|
|
21
21
|
ivar = "@#{arg}"
|
22
22
|
define_method(arg) do
|
23
|
-
|
24
|
-
|
23
|
+
if instance_variable_defined?(ivar)
|
24
|
+
val = instance_variable_get(ivar)
|
25
|
+
return val if val
|
26
|
+
end
|
25
27
|
instance_variable_set(ivar, (@lazy_source ||= lazy_source).send(arg))
|
26
28
|
end
|
27
29
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Grit
|
2
|
+
|
3
|
+
class Submodule
|
4
|
+
attr_reader :id
|
5
|
+
attr_reader :mode
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
# Create a Submodule containing just the specified attributes
|
9
|
+
# +repo+ is the Repo
|
10
|
+
# +atts+ is a Hash of instance variable data
|
11
|
+
#
|
12
|
+
# Returns Grit::Submodule (unbaked)
|
13
|
+
def self.create(repo, atts)
|
14
|
+
self.allocate.create_initialize(repo, atts)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Initializer for Submodule.create
|
18
|
+
# +repo+ is the Repo
|
19
|
+
# +atts+ is a Hash of instance variable data
|
20
|
+
#
|
21
|
+
# Returns Grit::Submodule
|
22
|
+
def create_initialize(repo, atts)
|
23
|
+
@repo = repo
|
24
|
+
atts.each do |k, v|
|
25
|
+
instance_variable_set("@#{k}".to_sym, v)
|
26
|
+
end
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
# The url of this submodule
|
31
|
+
# +ref+ is the committish that should be used to look up the url
|
32
|
+
#
|
33
|
+
# Returns String
|
34
|
+
def url(ref)
|
35
|
+
config = self.class.config(@repo, ref)
|
36
|
+
|
37
|
+
lookup = config.keys.inject({}) do |acc, key|
|
38
|
+
id = config[key]['id']
|
39
|
+
acc[id] = config[key]['url']
|
40
|
+
acc
|
41
|
+
end
|
42
|
+
|
43
|
+
lookup[@id]
|
44
|
+
end
|
45
|
+
|
46
|
+
# The configuration information for the given +repo+
|
47
|
+
# +repo+ is the Repo
|
48
|
+
# +ref+ is the committish (defaults to 'master')
|
49
|
+
#
|
50
|
+
# Returns a Hash of { <path:String> => { 'url' => <url:String>, 'id' => <id:String> } }
|
51
|
+
# Returns {} if no .gitmodules file was found
|
52
|
+
def self.config(repo, ref = "master")
|
53
|
+
commit = repo.commit(ref)
|
54
|
+
blob = commit.tree/'.gitmodules'
|
55
|
+
return {} unless blob
|
56
|
+
|
57
|
+
lines = blob.data.split("\n")
|
58
|
+
|
59
|
+
config = {}
|
60
|
+
current = nil
|
61
|
+
|
62
|
+
lines.each do |line|
|
63
|
+
if line =~ /^\[submodule "(.+)"\]$/
|
64
|
+
current = $1
|
65
|
+
config[current] = {}
|
66
|
+
config[current]['id'] = (commit.tree/current).id
|
67
|
+
elsif line =~ /^\t(\w+) = (.+)$/
|
68
|
+
config[current][$1] = $2
|
69
|
+
config[current]['id'] = (commit.tree/$2).id if $1 == 'path'
|
70
|
+
else
|
71
|
+
# ignore
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
config
|
76
|
+
end
|
77
|
+
|
78
|
+
# Pretty object inspection
|
79
|
+
def inspect
|
80
|
+
%Q{#<Grit::Submodule "#{@id}">}
|
81
|
+
end
|
82
|
+
end # Submodule
|
83
|
+
|
84
|
+
end # Grit
|
data/lib/grit/tree.rb
CHANGED
@@ -72,7 +72,7 @@ module Grit
|
|
72
72
|
when "link"
|
73
73
|
Blob.create(repo, :id => id, :mode => mode, :name => name)
|
74
74
|
when "commit"
|
75
|
-
|
75
|
+
Submodule.create(repo, :id => id, :mode => mode, :name => name)
|
76
76
|
else
|
77
77
|
raise "Invalid type: #{type}"
|
78
78
|
end
|
@@ -88,7 +88,11 @@ module Grit
|
|
88
88
|
#
|
89
89
|
# Returns Grit::Blob or Grit::Tree or nil if not found
|
90
90
|
def /(file)
|
91
|
-
|
91
|
+
if file =~ /\//
|
92
|
+
file.split("/").inject(self) { |acc, x| acc/x } rescue nil
|
93
|
+
else
|
94
|
+
self.contents.find { |c| c.name == file }
|
95
|
+
end
|
92
96
|
end
|
93
97
|
|
94
98
|
# Pretty object inspection
|
data/lib/open3_detach.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module Open3
|
2
|
+
extend self
|
3
|
+
|
4
|
+
def popen3(*cmd)
|
5
|
+
pw = IO::pipe # pipe[0] for read, pipe[1] for write
|
6
|
+
pr = IO::pipe
|
7
|
+
pe = IO::pipe
|
8
|
+
|
9
|
+
pid = fork{
|
10
|
+
# child
|
11
|
+
fork{
|
12
|
+
# grandchild
|
13
|
+
pw[1].close
|
14
|
+
STDIN.reopen(pw[0])
|
15
|
+
pw[0].close
|
16
|
+
|
17
|
+
pr[0].close
|
18
|
+
STDOUT.reopen(pr[1])
|
19
|
+
pr[1].close
|
20
|
+
|
21
|
+
pe[0].close
|
22
|
+
STDERR.reopen(pe[1])
|
23
|
+
pe[1].close
|
24
|
+
|
25
|
+
exec(*cmd)
|
26
|
+
}
|
27
|
+
exit!(0)
|
28
|
+
}
|
29
|
+
|
30
|
+
pw[0].close
|
31
|
+
pr[1].close
|
32
|
+
pe[1].close
|
33
|
+
Process.waitpid(pid)
|
34
|
+
pi = [pw[1], pr[0], pe[0]]
|
35
|
+
pw[1].sync = true
|
36
|
+
if defined? yield
|
37
|
+
begin
|
38
|
+
return yield(*pi)
|
39
|
+
ensure
|
40
|
+
Process.detach(pid) if pid
|
41
|
+
pi.each { |p| p.close unless p.closed? }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
pi
|
45
|
+
end
|
46
|
+
end
|
data/test/test_commit.rb
CHANGED
@@ -22,6 +22,12 @@ class TestCommit < Test::Unit::TestCase
|
|
22
22
|
assert_equal '80f136f', @r.commit('80f136f500dfdb8c3e8abf4ae716f875f0a1b57f').id_abbrev
|
23
23
|
end
|
24
24
|
|
25
|
+
# count
|
26
|
+
|
27
|
+
def test_count
|
28
|
+
assert_equal 107, Commit.count(@r, 'master')
|
29
|
+
end
|
30
|
+
|
25
31
|
# diff
|
26
32
|
|
27
33
|
def test_diff
|
data/test/test_git.rb
CHANGED
@@ -8,7 +8,7 @@ class TestGit < Test::Unit::TestCase
|
|
8
8
|
def teardown
|
9
9
|
Grit.debug = false
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def test_method_missing
|
13
13
|
assert_match(/^git version [\w\.]*$/, @git.version)
|
14
14
|
end
|
@@ -50,21 +50,15 @@ class TestGit < Test::Unit::TestCase
|
|
50
50
|
def test_raises_if_too_many_bytes
|
51
51
|
@git.instance_variable_set(:@bytes_read, 6000000)
|
52
52
|
assert_raises Grit::Git::GitTimeout do
|
53
|
-
@git.
|
53
|
+
@git.version
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_raises_on_slow_shell
|
58
|
-
Grit::Git.git_timeout = 0.
|
59
|
-
Open4.expects(:popen4).yields( nil, nil, mock(:read => proc { sleep 1 }), nil )
|
58
|
+
Grit::Git.git_timeout = 0.001
|
60
59
|
assert_raises Grit::Git::GitTimeout do
|
61
|
-
@git.
|
60
|
+
@git.version
|
62
61
|
end
|
63
|
-
|
64
|
-
|
65
|
-
def test_works_fine_if_quick
|
66
|
-
output = 'output'
|
67
|
-
Open4.expects(:popen4).yields( nil, nil, mock(:read => output), stub(:read => nil) )
|
68
|
-
assert_equal output, @git.something
|
62
|
+
Grit::Git.git_timeout = 5.0
|
69
63
|
end
|
70
64
|
end
|
data/test/test_repo.rb
CHANGED
@@ -35,6 +35,14 @@ class TestRepo < Test::Unit::TestCase
|
|
35
35
|
|
36
36
|
# heads
|
37
37
|
|
38
|
+
def test_current_head
|
39
|
+
@r = Repo.new(File.join(File.dirname(__FILE__), *%w[dot_git]), :is_bare => true)
|
40
|
+
head = @r.head
|
41
|
+
assert_equal Grit::Head, head.class
|
42
|
+
assert_equal 'master', head.name
|
43
|
+
assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', @r.commits(head.name).first.id
|
44
|
+
end
|
45
|
+
|
38
46
|
def test_heads_should_return_array_of_head_objects
|
39
47
|
@r.heads.each do |head|
|
40
48
|
assert_equal Grit::Head, head.class
|
data/test/test_tag.rb
CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/helper'
|
|
2
2
|
|
3
3
|
class TestTag < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@r = Repo.new(
|
5
|
+
@r = Repo.new(File.join(File.dirname(__FILE__), *%w[dot_git]), :is_bare => true)
|
6
6
|
end
|
7
7
|
|
8
8
|
# list_from_string
|
@@ -10,7 +10,7 @@ class TestTag < Test::Unit::TestCase
|
|
10
10
|
def test_list_from_string
|
11
11
|
tags = @r.tags
|
12
12
|
|
13
|
-
assert_equal
|
13
|
+
assert_equal 2, tags.size
|
14
14
|
assert_equal 'v0.7.0', tags.first.name
|
15
15
|
assert_equal 'f0055fda16c18fd8b27986dbf038c735b82198d7', tags.first.commit.id
|
16
16
|
end
|
@@ -22,4 +22,4 @@ class TestTag < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
assert_equal %Q{#<Grit::Tag "#{tag.name}">}, tag.inspect
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
data/test/test_tree.rb
CHANGED
@@ -50,12 +50,12 @@ class TestTree < Test::Unit::TestCase
|
|
50
50
|
assert_equal "grit.rb", tree.name
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
54
|
-
text = fixture('
|
53
|
+
def test_content_from_string_tree_should_return_submodule
|
54
|
+
text = fixture('ls_tree_submodule').split("\n").first
|
55
55
|
|
56
|
-
|
56
|
+
sm = @t.content_from_string(nil, text)
|
57
57
|
|
58
|
-
|
58
|
+
assert_kind_of Submodule, sm
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_content_from_string_invalid_type_should_raise
|
@@ -82,7 +82,7 @@ class TestTree < Test::Unit::TestCase
|
|
82
82
|
)
|
83
83
|
tree = @r.tree('master')
|
84
84
|
|
85
|
-
|
85
|
+
assert_equal 'd35b34c6e931b9da8f6941007a92c9c9a9b0141a', (tree/'bar').id
|
86
86
|
assert_equal '2afb47bcedf21663580d5e6d2f406f08f3f65f19', (tree/'foo').id
|
87
87
|
assert_equal 'f623ee576a09ca491c4a27e48c0dfe04be5f4a2e', (tree/'baz').id
|
88
88
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schacon-grit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-
|
13
|
+
date: 2008-11-07 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -52,7 +52,6 @@ extra_rdoc_files:
|
|
52
52
|
- README.txt
|
53
53
|
files:
|
54
54
|
- History.txt
|
55
|
-
- Manifest.txt
|
56
55
|
- README.txt
|
57
56
|
- Rakefile
|
58
57
|
- grit.gemspec
|
@@ -66,7 +65,6 @@ files:
|
|
66
65
|
- lib/grit/git-ruby/commit_db.rb
|
67
66
|
- lib/grit/git-ruby/file_index.rb
|
68
67
|
- lib/grit/git-ruby/git_object.rb
|
69
|
-
- lib/grit/git-ruby/internal
|
70
68
|
- lib/grit/git-ruby/internal/loose.rb
|
71
69
|
- lib/grit/git-ruby/internal/mmap.rb
|
72
70
|
- lib/grit/git-ruby/internal/pack.rb
|
@@ -81,11 +79,14 @@ files:
|
|
81
79
|
- lib/grit/ref.rb
|
82
80
|
- lib/grit/repo.rb
|
83
81
|
- lib/grit/status.rb
|
82
|
+
- lib/grit/submodule.rb
|
84
83
|
- lib/grit/tag.rb
|
85
84
|
- lib/grit/tree.rb
|
86
85
|
- lib/grit.rb
|
86
|
+
- lib/open3_detach.rb
|
87
|
+
- Manifest.txt
|
87
88
|
has_rdoc: true
|
88
|
-
homepage: http://github.com/
|
89
|
+
homepage: http://github.com/mojombo/grit
|
89
90
|
post_install_message:
|
90
91
|
rdoc_options:
|
91
92
|
- --main
|