git 1.0.3 → 1.0.4
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/doc/classes/Git/Base.html +336 -336
- data/doc/classes/Git/Branch.html +74 -74
- data/doc/classes/Git/Branches.html +36 -36
- data/doc/classes/Git/Diff.html +64 -64
- data/doc/classes/Git/Diff/DiffFile.html +12 -12
- data/doc/classes/Git/Lib.html +397 -318
- data/doc/classes/Git/Log.html +2 -2
- data/doc/classes/Git/Object.html +7 -7
- data/doc/classes/Git/Object/AbstractObject.html +91 -91
- data/doc/classes/Git/Object/Blob.html +6 -6
- data/doc/classes/Git/Object/Commit.html +134 -74
- data/doc/classes/Git/Object/Tag.html +7 -7
- data/doc/classes/Git/Object/Tree.html +36 -36
- data/doc/classes/Git/Path.html +24 -24
- data/doc/classes/Git/Remote.html +41 -41
- data/doc/created.rid +1 -1
- data/doc/files/lib/git/branch_rb.html +1 -1
- data/doc/files/lib/git/diff_rb.html +1 -1
- data/doc/files/lib/git/lib_rb.html +1 -1
- data/doc/files/lib/git/log_rb.html +1 -1
- data/doc/files/lib/git/object_rb.html +1 -1
- data/doc/fr_method_index.html +183 -179
- data/lib/git.rb +1 -1
- data/lib/git/branch.rb +1 -1
- data/lib/git/lib.rb +71 -29
- data/lib/git/log.rb +4 -4
- data/lib/git/object.rb +20 -6
- data/tests/units/test_lib.rb +4 -4
- data/tests/units/test_log.rb +2 -5
- data/tests/units/test_object.rb +3 -3
- metadata +2 -2
data/lib/git/branch.rb
CHANGED
data/lib/git/lib.rb
CHANGED
@@ -62,14 +62,29 @@ module Git
|
|
62
62
|
arr_opts = ['--pretty=oneline']
|
63
63
|
arr_opts << "-#{opts[:count]}" if opts[:count]
|
64
64
|
arr_opts << "--since=\"#{opts[:since]}\"" if opts[:since].is_a? String
|
65
|
-
arr_opts << "#{opts[:between][0]}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
|
65
|
+
arr_opts << "#{opts[:between][0].to_s}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
|
66
66
|
arr_opts << opts[:object] if opts[:object].is_a? String
|
67
67
|
arr_opts << '-- ' + opts[:path_limiter] if opts[:path_limiter].is_a? String
|
68
68
|
|
69
|
-
command_lines('log', arr_opts).map { |l| l.split.first }
|
69
|
+
command_lines('log', arr_opts, true).map { |l| l.split.first }
|
70
|
+
end
|
71
|
+
|
72
|
+
def full_log_commits(opts = {})
|
73
|
+
arr_opts = ['--pretty=raw']
|
74
|
+
arr_opts << "-#{opts[:count]}" if opts[:count]
|
75
|
+
arr_opts << "--since=\"#{opts[:since]}\"" if opts[:since].is_a? String
|
76
|
+
arr_opts << "#{opts[:between][0].to_s}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
|
77
|
+
arr_opts << opts[:object] if opts[:object].is_a? String
|
78
|
+
arr_opts << '-- ' + opts[:path_limiter] if opts[:path_limiter].is_a? String
|
79
|
+
|
80
|
+
full_log = command_lines('log', arr_opts, true)
|
81
|
+
process_commit_data(full_log)
|
70
82
|
end
|
71
83
|
|
72
84
|
def revparse(string)
|
85
|
+
if /\w{40}/.match(string) # passing in a sha - just no-op it
|
86
|
+
return string
|
87
|
+
end
|
73
88
|
command('rev-parse', string)
|
74
89
|
end
|
75
90
|
|
@@ -87,28 +102,52 @@ module Git
|
|
87
102
|
|
88
103
|
# returns useful array of raw commit object data
|
89
104
|
def commit_data(sha)
|
105
|
+
sha = sha.to_s
|
106
|
+
cdata = command_lines('cat-file', ['commit', sha])
|
107
|
+
process_commit_data(cdata, sha)
|
108
|
+
end
|
109
|
+
|
110
|
+
def process_commit_data(data, sha = nil)
|
90
111
|
in_message = false
|
91
112
|
|
92
|
-
|
93
|
-
|
94
|
-
|
113
|
+
if sha
|
114
|
+
hsh = {'sha' => sha, 'message' => '', 'parent' => []}
|
115
|
+
else
|
116
|
+
hsh_array = []
|
117
|
+
end
|
118
|
+
|
119
|
+
data.each do |line|
|
120
|
+
if in_message && line != ''
|
95
121
|
hsh['message'] += line + "\n"
|
96
122
|
end
|
97
|
-
|
123
|
+
|
98
124
|
if (line != '') && !in_message
|
99
125
|
data = line.split
|
100
126
|
key = data.shift
|
101
127
|
value = data.join(' ')
|
128
|
+
if key == 'commit'
|
129
|
+
sha = value
|
130
|
+
hsh_array << hsh if hsh
|
131
|
+
hsh = {'sha' => sha, 'message' => '', 'parent' => []}
|
132
|
+
end
|
102
133
|
if key == 'parent'
|
103
134
|
hsh[key] << value
|
104
135
|
else
|
105
136
|
hsh[key] = value
|
106
137
|
end
|
138
|
+
elsif in_message && line == ''
|
139
|
+
in_message = false
|
107
140
|
else
|
108
141
|
in_message = true
|
109
142
|
end
|
110
143
|
end
|
111
|
-
|
144
|
+
|
145
|
+
if hsh_array
|
146
|
+
hsh_array << hsh if hsh
|
147
|
+
hsh_array
|
148
|
+
else
|
149
|
+
hsh
|
150
|
+
end
|
112
151
|
end
|
113
152
|
|
114
153
|
def object_contents(sha)
|
@@ -422,34 +461,37 @@ module Git
|
|
422
461
|
|
423
462
|
private
|
424
463
|
|
425
|
-
def command_lines(cmd, opts = {})
|
426
|
-
command(cmd, opts).split("\n")
|
464
|
+
def command_lines(cmd, opts = {}, chdir = true)
|
465
|
+
command(cmd, opts, chdir).split("\n")
|
427
466
|
end
|
428
467
|
|
429
|
-
def command(cmd, opts = {})
|
430
|
-
ENV['GIT_DIR'] = @git_dir
|
431
|
-
ENV['GIT_INDEX_FILE'] = @git_index_file
|
432
|
-
ENV['
|
468
|
+
def command(cmd, opts = {}, chdir = true)
|
469
|
+
ENV['GIT_DIR'] = @git_dir if (@git_dir != ENV['GIT_DIR'])
|
470
|
+
ENV['GIT_INDEX_FILE'] = @git_index_file if (@git_index_file != ENV['GIT_INDEX_FILE'])
|
471
|
+
ENV['GIT_WORK_TREE'] = @git_work_dir if (@git_work_dir != ENV['GIT_WORK_TREE'])
|
433
472
|
path = @git_work_dir || @git_dir || @path
|
434
|
-
|
435
|
-
|
436
|
-
|
473
|
+
|
474
|
+
opts = opts.to_a.join(' ')
|
475
|
+
git_cmd = "git #{cmd} #{opts}"
|
476
|
+
|
477
|
+
out = nil
|
478
|
+
if chdir && (Dir.getwd != path)
|
479
|
+
Dir.chdir(path) { out = `git #{cmd} #{opts} 2>&1`.chomp }
|
480
|
+
else
|
437
481
|
out = `git #{cmd} #{opts} 2>&1`.chomp
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
if $?.exitstatus
|
446
|
-
|
447
|
-
return ''
|
448
|
-
end
|
449
|
-
raise Git::GitExecuteError.new(git_cmd + ':' + out.to_s)
|
482
|
+
end
|
483
|
+
|
484
|
+
#puts git_cmd
|
485
|
+
#puts out
|
486
|
+
#puts
|
487
|
+
|
488
|
+
if $?.exitstatus > 0
|
489
|
+
if $?.exitstatus == 1 && out == ''
|
490
|
+
return ''
|
450
491
|
end
|
451
|
-
out
|
492
|
+
raise Git::GitExecuteError.new(git_cmd + ':' + out.to_s)
|
452
493
|
end
|
494
|
+
out
|
453
495
|
end
|
454
496
|
|
455
497
|
end
|
data/lib/git/log.rb
CHANGED
@@ -41,12 +41,12 @@ module Git
|
|
41
41
|
|
42
42
|
def between(sha1, sha2 = nil)
|
43
43
|
dirty_log
|
44
|
-
@between = [
|
44
|
+
@between = [sha1, sha2]
|
45
45
|
return self
|
46
46
|
end
|
47
47
|
|
48
48
|
def to_s
|
49
|
-
self.map { |c| c.
|
49
|
+
self.map { |c| c.to_s }.join("\n")
|
50
50
|
end
|
51
51
|
|
52
52
|
|
@@ -84,9 +84,9 @@ module Git
|
|
84
84
|
|
85
85
|
# actually run the 'git log' command
|
86
86
|
def run_log
|
87
|
-
log = @base.lib.
|
87
|
+
log = @base.lib.full_log_commits(:count => @count, :object => @object,
|
88
88
|
:path_limiter => @path, :since => @since, :between => @between)
|
89
|
-
@commits = log.map { |
|
89
|
+
@commits = log.map { |c| Git::Object::Commit.new(@base, c['sha'], c) }
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
data/lib/git/object.rb
CHANGED
@@ -42,7 +42,7 @@ module Git
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def to_s
|
45
|
-
|
45
|
+
@objectish
|
46
46
|
end
|
47
47
|
|
48
48
|
def grep(string, path_limiter = nil, opts = {})
|
@@ -151,6 +151,13 @@ module Git
|
|
151
151
|
@committer = nil
|
152
152
|
@message = nil
|
153
153
|
|
154
|
+
def initialize(base, sha, init = nil)
|
155
|
+
super(base, sha)
|
156
|
+
if init
|
157
|
+
set_commit(init)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
154
161
|
def message
|
155
162
|
check_commit
|
156
163
|
@message
|
@@ -199,6 +206,17 @@ module Git
|
|
199
206
|
def diff_parent
|
200
207
|
diff(parent)
|
201
208
|
end
|
209
|
+
|
210
|
+
def set_commit(data)
|
211
|
+
if data['sha']
|
212
|
+
@sha = data['sha']
|
213
|
+
end
|
214
|
+
@committer = Git::Author.new(data['committer'])
|
215
|
+
@author = Git::Author.new(data['author'])
|
216
|
+
@tree = Tree.new(@base, data['tree'])
|
217
|
+
@parents = data['parent'].map{ |sha| Commit.new(@base, sha) }
|
218
|
+
@message = data['message'].chomp
|
219
|
+
end
|
202
220
|
|
203
221
|
private
|
204
222
|
|
@@ -210,11 +228,7 @@ module Git
|
|
210
228
|
def check_commit
|
211
229
|
if !@tree
|
212
230
|
data = @base.lib.commit_data(@objectish)
|
213
|
-
|
214
|
-
@author = Git::Author.new(data['author'])
|
215
|
-
@tree = Tree.new(@base, data['tree'])
|
216
|
-
@parents = data['parent'].map{ |sha| Commit.new(@base, sha) }
|
217
|
-
@message = data['message'].chomp
|
231
|
+
set_commit(data)
|
218
232
|
end
|
219
233
|
end
|
220
234
|
|
data/tests/units/test_lib.rb
CHANGED
@@ -42,11 +42,11 @@ class TestLib < Test::Unit::TestCase
|
|
42
42
|
a = @lib.log_commits :count => 20, :between => ['v2.5', 'v2.6']
|
43
43
|
assert_equal(2, a.size)
|
44
44
|
|
45
|
-
a = @lib.log_commits :count => 20, :
|
46
|
-
assert_equal(20, a.size)
|
47
|
-
|
48
|
-
a = @lib.log_commits :count => 20, :object => 'ex_dir/ex.txt'
|
45
|
+
a = @lib.log_commits :count => 20, :path_limiter => 'ex_dir/'
|
49
46
|
assert_equal(1, a.size)
|
47
|
+
|
48
|
+
a = @lib.full_log_commits :count => 20
|
49
|
+
assert_equal(20, a.size)
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_revparse
|
data/tests/units/test_log.rb
CHANGED
@@ -31,14 +31,11 @@ class TestLog < Test::Unit::TestCase
|
|
31
31
|
assert_equal(30, l.size)
|
32
32
|
end
|
33
33
|
|
34
|
-
def test_get_log_since_file
|
34
|
+
def test_get_log_since_file
|
35
35
|
l = @git.log.object('example.txt')
|
36
36
|
assert_equal(30, l.size)
|
37
|
-
|
38
|
-
l = @git.log.between('v2.5').object('example.txt')
|
39
|
-
assert_equal(3, l.size)
|
40
37
|
|
41
|
-
l = @git.log.between('v2.5', 'test').
|
38
|
+
l = @git.log.between('v2.5', 'test').path('example.txt')
|
42
39
|
assert_equal(1, l.size)
|
43
40
|
end
|
44
41
|
|
data/tests/units/test_object.rb
CHANGED
@@ -50,9 +50,9 @@ class TestObject < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_object_to_s
|
53
|
-
assert_equal('1cc8667014381e2788a94777532a788307f38d26', @commit.
|
54
|
-
assert_equal('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7', @tree.
|
55
|
-
assert_equal('ba492c62b6227d7f3507b4dcc6e6d5f13790eabf', @blob.
|
53
|
+
assert_equal('1cc8667014381e2788a94777532a788307f38d26', @commit.sha)
|
54
|
+
assert_equal('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7', @tree.sha)
|
55
|
+
assert_equal('ba492c62b6227d7f3507b4dcc6e6d5f13790eabf', @blob.sha)
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_object_size
|
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: 2007-11-
|
6
|
+
version: 1.0.4
|
7
|
+
date: 2007-11-19 00:00:00 -08:00
|
8
8
|
summary: A package for using Git in Ruby code.
|
9
9
|
require_paths:
|
10
10
|
- lib
|