git 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of git might be problematic. Click here for more details.
- data/README +4 -13
- data/lib/git.rb +6 -2
- data/lib/git/base.rb +37 -5
- data/lib/git/branch.rb +5 -0
- data/lib/git/branches.rb +12 -0
- data/lib/git/lib.rb +157 -25
- data/lib/git/lib.rb.orig +620 -0
- data/lib/git/object.rb +13 -5
- data/lib/git/stash.rb +26 -0
- data/lib/git/stashes.rb +49 -0
- data/tests/files/working.git/info/refs +10 -0
- data/tests/files/working.git/objects/info/packs +2 -0
- data/tests/files/working.git/objects/pack/pack-6e99d3a243c58205968336728d5637ce2a3b2aff.idx +0 -0
- data/tests/files/working.git/objects/pack/pack-6e99d3a243c58205968336728d5637ce2a3b2aff.pack +0 -0
- data/tests/files/working/dot_git/config +3 -0
- data/tests/test_helper.rb +11 -0
- data/tests/units/test_config.rb +3 -3
- data/tests/units/test_each_conflict.rb +49 -0
- data/tests/units/test_index_ops.rb +1 -1
- data/tests/units/test_lib.rb +9 -0
- data/tests/units/test_log.rb +2 -1
- data/tests/units/test_logger.rb +38 -0
- data/tests/units/test_object.rb +5 -0
- data/tests/units/test_stashes.rb +36 -0
- metadata +12 -2
data/lib/git/object.rb
CHANGED
@@ -124,6 +124,14 @@ module Git
|
|
124
124
|
alias_method :subtrees, :trees
|
125
125
|
alias_method :subdirectories, :trees
|
126
126
|
|
127
|
+
def full_tree
|
128
|
+
@base.lib.full_tree(@objectish)
|
129
|
+
end
|
130
|
+
|
131
|
+
def depth
|
132
|
+
@base.lib.tree_depth(@objectish)
|
133
|
+
end
|
134
|
+
|
127
135
|
private
|
128
136
|
|
129
137
|
def setup
|
@@ -136,8 +144,8 @@ module Git
|
|
136
144
|
@trees = {}
|
137
145
|
@blobs = {}
|
138
146
|
data = @base.lib.ls_tree(@objectish)
|
139
|
-
data['tree'].each { |k, d| @trees[k] = Tree.new(@base, d[:sha], d[:mode]) }
|
140
|
-
data['blob'].each { |k, d| @blobs[k] = Blob.new(@base, d[:sha], d[:mode]) }
|
147
|
+
data['tree'].each { |k, d| @trees[k] = Git::Object::Tree.new(@base, d[:sha], d[:mode]) }
|
148
|
+
data['blob'].each { |k, d| @blobs[k] = Git::Object::Blob.new(@base, d[:sha], d[:mode]) }
|
141
149
|
end
|
142
150
|
end
|
143
151
|
|
@@ -213,8 +221,8 @@ module Git
|
|
213
221
|
end
|
214
222
|
@committer = Git::Author.new(data['committer'])
|
215
223
|
@author = Git::Author.new(data['author'])
|
216
|
-
@tree = Tree.new(@base, data['tree'])
|
217
|
-
@parents = data['parent'].map{ |sha| Commit.new(@base, sha) }
|
224
|
+
@tree = Git::Object::Tree.new(@base, data['tree'])
|
225
|
+
@parents = data['parent'].map{ |sha| Git::Object::Commit.new(@base, sha) }
|
218
226
|
@message = data['message'].chomp
|
219
227
|
end
|
220
228
|
|
@@ -259,7 +267,7 @@ module Git
|
|
259
267
|
if sha == ''
|
260
268
|
raise Git::GitTagNameDoesNotExist.new(objectish)
|
261
269
|
end
|
262
|
-
return Tag.new(base, sha, objectish)
|
270
|
+
return Git::Object::Tag.new(base, sha, objectish)
|
263
271
|
else
|
264
272
|
if !type
|
265
273
|
type = base.lib.object_type(objectish)
|
data/lib/git/stash.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Git
|
2
|
+
class Stash
|
3
|
+
def initialize(base, message, existing=false)
|
4
|
+
@base = base
|
5
|
+
@message = message
|
6
|
+
save if existing == false
|
7
|
+
end
|
8
|
+
|
9
|
+
def save
|
10
|
+
@saved = @base.lib.stash_save(@message)
|
11
|
+
end
|
12
|
+
|
13
|
+
def saved?
|
14
|
+
@saved
|
15
|
+
end
|
16
|
+
|
17
|
+
def message
|
18
|
+
@message
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
message
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/git/stashes.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Git
|
2
|
+
|
3
|
+
# object that holds all the available stashes
|
4
|
+
class Stashes
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
@base = nil
|
8
|
+
@stashes = nil
|
9
|
+
|
10
|
+
def initialize(base)
|
11
|
+
@stashes = []
|
12
|
+
|
13
|
+
@base = base
|
14
|
+
|
15
|
+
@base.lib.stashes_all.each do |id, message|
|
16
|
+
@stashes.unshift(Git::Stash.new(@base, message, true))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def save(message)
|
21
|
+
s = Git::Stash.new(@base, message)
|
22
|
+
@stashes.unshift(s) if s.saved?
|
23
|
+
end
|
24
|
+
|
25
|
+
def apply(index=0)
|
26
|
+
@base.lib.stash_apply(index.to_i)
|
27
|
+
end
|
28
|
+
|
29
|
+
def clear
|
30
|
+
@base.lib.stash_clear
|
31
|
+
@stashes = []
|
32
|
+
end
|
33
|
+
|
34
|
+
def size
|
35
|
+
@stashes.size
|
36
|
+
end
|
37
|
+
|
38
|
+
def each
|
39
|
+
@stashes.each do |s|
|
40
|
+
yield s
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def [](index)
|
45
|
+
@stashes[index.to_i]
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
5e53019b3238362144c2766f02a2c00d91fcc023 refs/heads/git_grep
|
2
|
+
5e392652a881999392c2757cf9b783c5d47b67f7 refs/heads/master
|
3
|
+
1cc8667014381e2788a94777532a788307f38d26 refs/heads/test
|
4
|
+
3a9f195756f5bd26b67c5e1fffd92d68d61be14e refs/heads/test_branches
|
5
|
+
3a9f195756f5bd26b67c5e1fffd92d68d61be14e refs/heads/test_object
|
6
|
+
935badc874edd62a8629aaf103418092c73f0a56 refs/tags/gitsearch1
|
7
|
+
546bec6f8872efa41d5d97a369f669165ecda0de refs/tags/v2.5
|
8
|
+
3a9f195756f5bd26b67c5e1fffd92d68d61be14e refs/tags/v2.6
|
9
|
+
3a9f195756f5bd26b67c5e1fffd92d68d61be14e refs/tags/v2.7
|
10
|
+
5e53019b3238362144c2766f02a2c00d91fcc023 refs/tags/v2.8
|
Binary file
|
Binary file
|
data/tests/test_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'logger'
|
3
4
|
require File.dirname(__FILE__) + '/../lib/git'
|
4
5
|
|
5
6
|
class Test::Unit::TestCase
|
@@ -28,6 +29,16 @@ class Test::Unit::TestCase
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
32
|
+
|
33
|
+
def with_temp_bare
|
34
|
+
in_temp_dir do |path|
|
35
|
+
g = Git.clone(@wbare, 'new')
|
36
|
+
Dir.chdir('new') do
|
37
|
+
yield g
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
31
42
|
def create_temp_repo(clone_path)
|
32
43
|
filename = 'git_test' + Time.now.to_i.to_s + rand(300).to_s.rjust(3, '0')
|
33
44
|
@tmp_path = File.join("/tmp/", filename)
|
data/tests/units/test_config.rb
CHANGED
@@ -10,19 +10,19 @@ class TestConfig < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
def test_config
|
12
12
|
c = @git.config
|
13
|
-
assert_equal('
|
13
|
+
assert_equal('Scott Chacon', c['user.name'])
|
14
14
|
assert_equal('false', c['core.bare'])
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_read_config
|
18
|
-
assert_equal('
|
18
|
+
assert_equal('Scott Chacon', @git.config('user.name'))
|
19
19
|
assert_equal('false', @git.config('core.bare'))
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_set_config
|
23
23
|
in_temp_dir do |path|
|
24
24
|
g = Git.clone(@wbare, 'bare')
|
25
|
-
assert_equal('
|
25
|
+
assert_equal('Scott Chacon', g.config('user.name'))
|
26
26
|
g.config('user.name', 'bully')
|
27
27
|
assert_equal('bully', g.config('user.name'))
|
28
28
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
4
|
+
|
5
|
+
class TestEachConflict < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
set_file_paths
|
9
|
+
#@git = Git.open(@wdir, :log => Logger.new(STDOUT))
|
10
|
+
@git = Git.open(@wdir)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_conflicts
|
14
|
+
in_temp_dir do |path|
|
15
|
+
g = Git.clone(@wbare, 'branch_merge_test')
|
16
|
+
Dir.chdir('branch_merge_test') do
|
17
|
+
|
18
|
+
g.branch('new_branch').in_branch('test') do
|
19
|
+
new_file('example.txt', "1\n2\n3")
|
20
|
+
g.add
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
g.branch('new_branch2').in_branch('test') do
|
25
|
+
new_file('example.txt', "1\n4\n3")
|
26
|
+
g.add
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
g.merge('new_branch')
|
32
|
+
begin
|
33
|
+
g.merge('new_branch2')
|
34
|
+
rescue
|
35
|
+
end
|
36
|
+
|
37
|
+
g.each_conflict do |file, your, their|
|
38
|
+
assert_equal('example.txt', file)
|
39
|
+
assert_equal("1\n2\n3\n", File.read(your))
|
40
|
+
assert_equal("1\n4\n3\n", File.read(their))
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
end
|
data/tests/units/test_lib.rb
CHANGED
@@ -102,6 +102,15 @@ class TestLib < Test::Unit::TestCase
|
|
102
102
|
assert_equal('+refs/heads/*:refs/remotes/working/*', config['fetch'])
|
103
103
|
end
|
104
104
|
|
105
|
+
|
106
|
+
def test_ls_tree
|
107
|
+
tree = @lib.ls_tree('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7')
|
108
|
+
assert_equal("3aac4b445017a8fc07502670ec2dbf744213dd48", tree['blob']['example.txt'][:sha])
|
109
|
+
assert_equal("100644", tree['blob']['example.txt'][:mode])
|
110
|
+
assert(tree['tree'])
|
111
|
+
end
|
112
|
+
|
113
|
+
|
105
114
|
# options this will accept
|
106
115
|
# :treeish
|
107
116
|
# :path_limiter
|
data/tests/units/test_log.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'logger'
|
3
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
4
|
+
|
5
|
+
class TestLogger < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
set_file_paths
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_logger
|
12
|
+
log = Tempfile.new('logfile')
|
13
|
+
log.close
|
14
|
+
|
15
|
+
logger = Logger.new(log.path)
|
16
|
+
logger.level = Logger::DEBUG
|
17
|
+
|
18
|
+
@git = Git.open(@wdir, :log => logger)
|
19
|
+
@git.branches.size
|
20
|
+
|
21
|
+
logc = File.read(log.path)
|
22
|
+
assert(/INFO -- : git branch -a/.match(logc))
|
23
|
+
assert(/DEBUG -- : \* git_grep/.match(logc))
|
24
|
+
|
25
|
+
log = Tempfile.new('logfile')
|
26
|
+
log.close
|
27
|
+
logger = Logger.new(log.path)
|
28
|
+
logger.level = Logger::INFO
|
29
|
+
|
30
|
+
@git = Git.open(@wdir, :log => logger)
|
31
|
+
@git.branches.size
|
32
|
+
|
33
|
+
logc = File.read(log.path)
|
34
|
+
assert(/INFO -- : git branch -a/.match(logc))
|
35
|
+
assert(!/DEBUG -- : \* git_grep/.match(logc))
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/tests/units/test_object.rb
CHANGED
@@ -72,6 +72,11 @@ class TestObject < Test::Unit::TestCase
|
|
72
72
|
assert_equal(1, o.blobs.size)
|
73
73
|
assert_equal(1, o.subtrees.size)
|
74
74
|
assert_equal(1, o.trees['ex_dir'].blobs.size)
|
75
|
+
|
76
|
+
assert_equal(2, o.full_tree.size)
|
77
|
+
assert_equal("100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\tex_dir/ex.txt", o.full_tree.first)
|
78
|
+
|
79
|
+
assert_equal(2, o.depth)
|
75
80
|
|
76
81
|
o = @git.gtree('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7')
|
77
82
|
assert(o.is_a?(Git::Object::Tree))
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
4
|
+
|
5
|
+
class TestStashes < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
set_file_paths
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_stash_unstash
|
11
|
+
in_temp_dir do |path|
|
12
|
+
g = Git.clone(@wbare, 'stash_test')
|
13
|
+
Dir.chdir('stash_test') do
|
14
|
+
assert_equal(0, g.branch.stashes.size)
|
15
|
+
new_file('test-file1', 'blahblahblah1')
|
16
|
+
new_file('test-file2', 'blahblahblah2')
|
17
|
+
assert(g.status.untracked.assoc('test-file1'))
|
18
|
+
|
19
|
+
g.add
|
20
|
+
|
21
|
+
assert(g.status.added.assoc('test-file1'))
|
22
|
+
|
23
|
+
g.branch.stashes.save('testing')
|
24
|
+
|
25
|
+
g.reset
|
26
|
+
assert_nil(g.status.untracked.assoc('test-file1'))
|
27
|
+
assert_nil(g.status.added.assoc('test-file1'))
|
28
|
+
|
29
|
+
g.branch.stashes.apply
|
30
|
+
|
31
|
+
assert(g.status.added.assoc('test-file1'))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: git
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date:
|
6
|
+
version: 1.0.5
|
7
|
+
date: 2008-03-23 00:00:00 -07:00
|
8
8
|
summary: A package for using Git in Ruby code.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -38,11 +38,14 @@ files:
|
|
38
38
|
- lib/git/diff.rb
|
39
39
|
- lib/git/index.rb
|
40
40
|
- lib/git/lib.rb
|
41
|
+
- lib/git/lib.rb.orig
|
41
42
|
- lib/git/log.rb
|
42
43
|
- lib/git/object.rb
|
43
44
|
- lib/git/path.rb
|
44
45
|
- lib/git/remote.rb
|
45
46
|
- lib/git/repository.rb
|
47
|
+
- lib/git/stash.rb
|
48
|
+
- lib/git/stashes.rb
|
46
49
|
- lib/git/status.rb
|
47
50
|
- lib/git/working_directory.rb
|
48
51
|
- tests/all_tests.rb
|
@@ -490,6 +493,7 @@ files:
|
|
490
493
|
- tests/files/working.git/hooks/pre-rebase
|
491
494
|
- tests/files/working.git/hooks/update
|
492
495
|
- tests/files/working.git/info/exclude
|
496
|
+
- tests/files/working.git/info/refs
|
493
497
|
- tests/files/working.git/objects/00
|
494
498
|
- tests/files/working.git/objects/01
|
495
499
|
- tests/files/working.git/objects/02
|
@@ -856,6 +860,9 @@ files:
|
|
856
860
|
- tests/files/working.git/objects/fb/8e78840d79085abf50edebf5b9d6b73ee0fb4c
|
857
861
|
- tests/files/working.git/objects/fc/b49fa99454f804799a12095292edbca48779ab
|
858
862
|
- tests/files/working.git/objects/fe/b2ccf88397c2d93f381176067be2727eba330b
|
863
|
+
- tests/files/working.git/objects/info/packs
|
864
|
+
- tests/files/working.git/objects/pack/pack-6e99d3a243c58205968336728d5637ce2a3b2aff.idx
|
865
|
+
- tests/files/working.git/objects/pack/pack-6e99d3a243c58205968336728d5637ce2a3b2aff.pack
|
859
866
|
- tests/files/working.git/refs/heads
|
860
867
|
- tests/files/working.git/refs/tags
|
861
868
|
- tests/files/working.git/refs/heads/git_grep
|
@@ -873,15 +880,18 @@ files:
|
|
873
880
|
- tests/units/test_branch.rb
|
874
881
|
- tests/units/test_config.rb
|
875
882
|
- tests/units/test_diff.rb
|
883
|
+
- tests/units/test_each_conflict.rb
|
876
884
|
- tests/units/test_git_path.rb
|
877
885
|
- tests/units/test_index_ops.rb
|
878
886
|
- tests/units/test_init.rb
|
879
887
|
- tests/units/test_lib.rb
|
880
888
|
- tests/units/test_log.rb
|
889
|
+
- tests/units/test_logger.rb
|
881
890
|
- tests/units/test_merge.rb
|
882
891
|
- tests/units/test_object.rb
|
883
892
|
- tests/units/test_remotes.rb
|
884
893
|
- tests/units/test_repack.rb
|
894
|
+
- tests/units/test_stashes.rb
|
885
895
|
- tests/units/test_tags.rb
|
886
896
|
- tests/units/test_tree_ops.rb
|
887
897
|
- doc/classes
|