libdolt 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -16
- data/Readme.md +2 -3
- data/lib/libdolt/git/archiver.rb +15 -40
- data/lib/libdolt/git/blame.rb +4 -0
- data/lib/libdolt/git/process.rb +44 -0
- data/lib/libdolt/git/repository.rb +56 -101
- data/lib/libdolt/git.rb +42 -0
- data/lib/libdolt/repo_actions.rb +28 -36
- data/lib/libdolt/version.rb +1 -1
- data/lib/libdolt.rb +1 -3
- data/libdolt.gemspec +1 -5
- data/test/libdolt/git/archiver_test.rb +28 -91
- data/test/libdolt/git/blame_test.rb +40 -4
- data/test/libdolt/git/commit_test.rb +1 -3
- data/test/libdolt/git/repository_test.rb +92 -171
- data/test/libdolt/repo_actions_test.rb +102 -144
- data/test/test_helper.rb +22 -2
- metadata +9 -71
@@ -29,30 +29,18 @@ class StubRepository
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
class StubProcessStatus
|
33
|
-
attr_reader :exitstatus
|
34
|
-
def initialize(code)
|
35
|
-
@exitstatus = code
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
32
|
describe Dolt::Git::Archiver do
|
40
|
-
include EM::MiniTest::Spec
|
41
|
-
|
42
33
|
describe "archive" do
|
43
34
|
before do
|
44
35
|
@archiver = Dolt::Git::Archiver.new("/work", "/cache")
|
45
36
|
end
|
46
37
|
|
47
|
-
it "
|
38
|
+
it "returns existing cached file" do
|
48
39
|
File.stubs(:exists?).with("/cache/gts-mainline-master.tar.gz").returns(true)
|
49
40
|
repo = StubRepository.new("gts/mainline")
|
50
41
|
|
51
|
-
@archiver.archive(repo, "master", :tar)
|
52
|
-
|
53
|
-
done!
|
54
|
-
end
|
55
|
-
wait!
|
42
|
+
filename = @archiver.archive(repo, "master", :tar)
|
43
|
+
assert_equal "/cache/gts-mainline-master.tar.gz", filename
|
56
44
|
end
|
57
45
|
|
58
46
|
it "generates tarball" do
|
@@ -60,19 +48,30 @@ describe Dolt::Git::Archiver do
|
|
60
48
|
|
61
49
|
cmd = "sh -c 'git --git-dir /repos/gts/mainline.git archive --prefix='gts-mainline/' " +
|
62
50
|
"--format=tar master | gzip -m > /work/gts-mainline-master.tar.gz'"
|
63
|
-
|
64
|
-
|
51
|
+
Dolt::Git.expects(:shell).with(cmd).returns(Dolt::FakeProcess.new(0))
|
52
|
+
FileUtils.stubs(:mv)
|
65
53
|
|
66
54
|
@archiver.archive(repo, "master", :tar)
|
67
55
|
end
|
68
56
|
|
57
|
+
it "does not allow arbitrary commands" do
|
58
|
+
repo = StubRepository.new("gts/mainline")
|
59
|
+
|
60
|
+
cmd = "sh -c 'git --git-dir /repos/gts/mainline.git archive --prefix='gts-mainline/' " +
|
61
|
+
"--format=tar master\\;\\ rm\\ -fr\\ / | gzip -m > /work/gts-mainline-master\\;\\ rm\\ -fr\\ -.tar.gz'"
|
62
|
+
Dolt::Git.expects(:shell).with(cmd).returns(Dolt::FakeProcess.new(0))
|
63
|
+
FileUtils.stubs(:mv)
|
64
|
+
|
65
|
+
@archiver.archive(repo, "master; rm -fr /", :tar)
|
66
|
+
end
|
67
|
+
|
69
68
|
it "uses gzip format from string" do
|
70
69
|
repo = StubRepository.new("gts/mainline")
|
71
70
|
|
72
71
|
cmd = "sh -c 'git --git-dir /repos/gts/mainline.git archive --prefix='gts-mainline/' " +
|
73
72
|
"--format=tar master | gzip -m > /work/gts-mainline-master.tar.gz'"
|
74
|
-
|
75
|
-
|
73
|
+
Dolt::Git.expects(:shell).with(cmd).returns(Dolt::FakeProcess.new(0))
|
74
|
+
FileUtils.stubs(:mv)
|
76
75
|
|
77
76
|
@archiver.archive(repo, "master", "tar")
|
78
77
|
end
|
@@ -82,8 +81,8 @@ describe Dolt::Git::Archiver do
|
|
82
81
|
|
83
82
|
cmd = "sh -c 'git --git-dir /repos/gts/mainline.git archive --prefix='gts-mainline/' " +
|
84
83
|
"--format=zip master > /work/gts-mainline-master.zip'"
|
85
|
-
|
86
|
-
|
84
|
+
Dolt::Git.expects(:shell).with(cmd).returns(Dolt::FakeProcess.new(0))
|
85
|
+
FileUtils.stubs(:mv)
|
87
86
|
|
88
87
|
@archiver.archive(repo, "master", "zip")
|
89
88
|
end
|
@@ -92,9 +91,7 @@ describe Dolt::Git::Archiver do
|
|
92
91
|
FileUtils.expects(:mv).with("/work/gts-mainline-master.tar.gz",
|
93
92
|
"/cache/gts-mainline-master.tar.gz")
|
94
93
|
repo = StubRepository.new("gts/mainline")
|
95
|
-
|
96
|
-
EMPessimistic::DeferrableChildProcess.expects(:open).returns(d)
|
97
|
-
d.succeed("", StubProcessStatus.new(0))
|
94
|
+
Dolt::Git.stubs(:open).returns(Dolt::FakeProcess.new(0))
|
98
95
|
|
99
96
|
@archiver.archive(repo, "master", :tar)
|
100
97
|
end
|
@@ -103,80 +100,20 @@ describe Dolt::Git::Archiver do
|
|
103
100
|
FileUtils.expects(:mv).with("/work/gts-mainline-master.tar.gz",
|
104
101
|
"/cache/gts-mainline-master.tar.gz").never
|
105
102
|
repo = StubRepository.new("gts/mainline")
|
106
|
-
|
107
|
-
EMPessimistic::DeferrableChildProcess.expects(:open).returns(d)
|
108
|
-
d.fail("", StubProcessStatus.new(1))
|
109
|
-
|
110
|
-
@archiver.archive(repo, "master", :tar)
|
111
|
-
end
|
112
|
-
|
113
|
-
it "resolves promise with generated filename" do
|
114
|
-
FileUtils.stubs(:mv)
|
115
|
-
repo = StubRepository.new("gts/mainline")
|
116
|
-
d = EM::DefaultDeferrable.new
|
117
|
-
EMPessimistic::DeferrableChildProcess.expects(:open).returns(d)
|
118
|
-
d.succeed("", StubProcessStatus.new(0))
|
119
|
-
|
120
|
-
@archiver.archive(repo, "master", :tar).then do |filename|
|
121
|
-
assert_equal "/cache/gts-mainline-master.tar.gz", filename
|
122
|
-
done!
|
123
|
-
end
|
124
|
-
wait!
|
125
|
-
end
|
126
|
-
|
127
|
-
it "rejects promise when failing to archive" do
|
128
|
-
repo = StubRepository.new("gts/mainline")
|
129
|
-
d = EM::DefaultDeferrable.new
|
130
|
-
EMPessimistic::DeferrableChildProcess.expects(:open).returns(d)
|
131
|
-
d.fail("It done failed", StubProcessStatus.new(1))
|
132
|
-
|
133
|
-
@archiver.archive(repo, "master", :tar).errback do |err|
|
134
|
-
assert_match "It done failed", err.message
|
135
|
-
done!
|
136
|
-
end
|
137
|
-
wait!
|
138
|
-
end
|
103
|
+
Dolt::Git.expects(:shell).returns(Dolt::FakeProcess.new(1))
|
139
104
|
|
140
|
-
|
141
|
-
|
142
|
-
repo = StubRepository.new("gts/mainline")
|
143
|
-
d = EM::DefaultDeferrable.new
|
144
|
-
EMPessimistic::DeferrableChildProcess.expects(:open).once.returns(d)
|
145
|
-
callbacks = 0
|
146
|
-
blk = lambda do |filename|
|
147
|
-
assert_equal "/cache/gts-mainline-master.tar.gz", filename
|
148
|
-
callbacks += 1
|
149
|
-
done! if callbacks == 2
|
105
|
+
assert_raises Exception do
|
106
|
+
@archiver.archive(repo, "master", :tar)
|
150
107
|
end
|
151
|
-
|
152
|
-
@archiver.archive(repo, "master", :tar).then(&blk)
|
153
|
-
@archiver.archive(repo, "master", :tar).then(&blk)
|
154
|
-
|
155
|
-
wait!
|
156
|
-
d.succeed("", StubProcessStatus.new(0))
|
157
108
|
end
|
158
109
|
|
159
|
-
it "
|
110
|
+
it "returns generated filename" do
|
160
111
|
FileUtils.stubs(:mv)
|
112
|
+
Dolt::Git.stubs(:open).returns(Dolt::FakeProcess.new(0))
|
161
113
|
repo = StubRepository.new("gts/mainline")
|
162
|
-
d = EM::DefaultDeferrable.new
|
163
|
-
EMPessimistic::DeferrableChildProcess.expects(:open).twice.returns(d)
|
164
|
-
callbacks = 0
|
165
|
-
|
166
|
-
@archiver.archive(repo, "master", :tar).then do |filename|
|
167
|
-
assert_equal "/cache/gts-mainline-master.tar.gz", filename
|
168
|
-
callbacks += 1
|
169
|
-
done! if callbacks == 2
|
170
|
-
end
|
171
|
-
|
172
|
-
@archiver.archive(repo, "master", :zip).then do |filename|
|
173
|
-
assert_equal "/cache/gts-mainline-master.zip", filename
|
174
|
-
callbacks += 1
|
175
|
-
done! if callbacks == 2
|
176
|
-
end
|
177
114
|
|
178
|
-
|
179
|
-
|
115
|
+
filename = @archiver.archive(repo, "master", :tar)
|
116
|
+
assert_equal "/cache/gts-mainline-master.tar.gz", filename
|
180
117
|
end
|
181
118
|
end
|
182
119
|
end
|
@@ -19,11 +19,9 @@ require "test_helper"
|
|
19
19
|
require "libdolt/git/blame"
|
20
20
|
|
21
21
|
describe Dolt::Git::Blame do
|
22
|
-
include EM::MiniTest::Spec
|
23
|
-
|
24
22
|
describe "parse" do
|
25
23
|
before do
|
26
|
-
|
24
|
+
blame = <<-GIT
|
27
25
|
906d67b4f3e5de7364ba9b57d174d8998d53ced6 1 1 17
|
28
26
|
author Christian Johansen
|
29
27
|
author-mail <christian@cjohansen.no>
|
@@ -93,7 +91,7 @@ beb65bee5619c651532179b19421363ead2c2a44 22 22
|
|
93
91
|
end
|
94
92
|
GIT
|
95
93
|
|
96
|
-
@blame = Dolt::Git::Blame.parse_porcelain(
|
94
|
+
@blame = Dolt::Git::Blame.parse_porcelain(blame)
|
97
95
|
end
|
98
96
|
|
99
97
|
it "has chunks" do
|
@@ -125,4 +123,42 @@ beb65bee5619c651532179b19421363ead2c2a44 22 22
|
|
125
123
|
assert_equal @blame.chunks[2][:committer], @blame.chunks[0][:committer]
|
126
124
|
end
|
127
125
|
end
|
126
|
+
|
127
|
+
describe "parsing invalid data" do
|
128
|
+
before do
|
129
|
+
@blame = <<-EOF
|
130
|
+
usage: git blame [options] [rev-opts] [rev] [--] file
|
131
|
+
[rev-opts] are documented in git-rev-list(1)
|
132
|
+
|
133
|
+
--incremental Show blame entries as we find them, incrementally
|
134
|
+
-b Show blank SHA-1 for boundary commits (Default: off)
|
135
|
+
--root Do not treat root commits as boundaries (Default: off)
|
136
|
+
--show-stats Show work cost statistics
|
137
|
+
--score-debug Show output score for blame entries
|
138
|
+
-f, --show-name Show original filename (Default: auto)
|
139
|
+
-n, --show-number Show original linenumber (Default: off)
|
140
|
+
-p, --porcelain Show in a format designed for machine consumption
|
141
|
+
--line-porcelain Show porcelain format with per-line commit information
|
142
|
+
-c Use the same output mode as git-annotate (Default: off)
|
143
|
+
-t Show raw timestamp (Default: off)
|
144
|
+
-l Show long commit SHA1 (Default: off)
|
145
|
+
-s Suppress author name and timestamp (Default: off)
|
146
|
+
-e, --show-email Show author email instead of name (Default: off)
|
147
|
+
-w Ignore whitespace differences
|
148
|
+
--minimal Spend extra cycles to find better match
|
149
|
+
-S <file> Use revisions from <file> instead of calling git-rev-list
|
150
|
+
--contents <file> Use <file>'s contents as the final image
|
151
|
+
-C[<score>] Find line copies within and across files
|
152
|
+
-M[<score>] Find line movements within and across files
|
153
|
+
-L <n,m> Process only line range n,m, counting from 1
|
154
|
+
--abbrev[=<n>] use <n> digits to display SHA-1s
|
155
|
+
EOF
|
156
|
+
end
|
157
|
+
|
158
|
+
it "raises an error" do
|
159
|
+
assert_raises Dolt::Git::InvalidBlameFormat do
|
160
|
+
Dolt::Git::Blame.parse_porcelain(@blame)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
128
164
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#--
|
3
|
-
# Copyright (C) 2012 Gitorious AS
|
3
|
+
# Copyright (C) 2012-2013 Gitorious AS
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Affero General Public License as published by
|
@@ -19,8 +19,6 @@ require "test_helper"
|
|
19
19
|
require "libdolt/git/commit"
|
20
20
|
|
21
21
|
describe Dolt::Git::Commit do
|
22
|
-
include EM::MiniTest::Spec
|
23
|
-
|
24
22
|
describe "parse" do
|
25
23
|
before do
|
26
24
|
@log = <<-GIT
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#--
|
3
|
-
# Copyright (C) 2012 Gitorious AS
|
3
|
+
# Copyright (C) 2012-2013 Gitorious AS
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Affero General Public License as published by
|
@@ -19,274 +19,195 @@ require "test_helper"
|
|
19
19
|
require "libdolt/git/repository"
|
20
20
|
require "time"
|
21
21
|
require "ostruct"
|
22
|
+
require "mocha/setup"
|
22
23
|
|
23
24
|
describe Dolt::Git::Repository do
|
24
|
-
include EM::MiniTest::Spec
|
25
25
|
before { @repository = Dolt::Git::Repository.new(".") }
|
26
26
|
|
27
27
|
describe "#submodules" do
|
28
|
-
it "returns
|
29
|
-
|
30
|
-
|
31
|
-
assert deferrable.respond_to?(:errback)
|
32
|
-
end
|
28
|
+
it "returns list of submodules" do
|
29
|
+
submodules = @repository.submodules("c1f6cd9")
|
30
|
+
url = "git://gitorious.org/gitorious/ui3.git"
|
33
31
|
|
34
|
-
|
35
|
-
@repository.submodules("c1f6cd9").callback do |submodules|
|
36
|
-
url = "git://gitorious.org/gitorious/ui3.git"
|
37
|
-
assert_equal [{ :path => "vendor/ui", :url => url }], submodules
|
38
|
-
done!
|
39
|
-
end
|
40
|
-
wait!
|
32
|
+
assert_equal [{ :path => "vendor/ui", :url => url }], submodules
|
41
33
|
end
|
42
34
|
|
43
|
-
it "
|
44
|
-
@repository.submodules("26139a3")
|
45
|
-
|
46
|
-
done!
|
47
|
-
end
|
48
|
-
wait!
|
35
|
+
it "returns empty array if no submodules" do
|
36
|
+
submodules = @repository.submodules("26139a3")
|
37
|
+
assert_equal [], submodules
|
49
38
|
end
|
50
39
|
end
|
51
40
|
|
52
41
|
describe "#tree" do
|
53
42
|
it "includes submodule data for trees" do
|
54
|
-
@repository.tree("3dc532f", "vendor")
|
55
|
-
|
43
|
+
tree = @repository.tree("3dc532f", "vendor")
|
44
|
+
|
45
|
+
assert_equal({
|
56
46
|
:type => :submodule,
|
57
47
|
:filemode => 57344,
|
58
48
|
:name => "ui",
|
59
49
|
:oid => "d167e3e1c17a27e4cf459dd380670801b0659659",
|
60
50
|
:url => "git://gitorious.org/gitorious/ui3.git"
|
61
51
|
}, tree.entries.first)
|
62
|
-
done!
|
63
|
-
end
|
64
|
-
wait!
|
65
52
|
end
|
66
53
|
end
|
67
54
|
|
68
55
|
describe "#tree_entry" do
|
69
56
|
it "includes submodule data for trees" do
|
70
|
-
@repository.tree_entry("3dc532f", "vendor")
|
71
|
-
|
57
|
+
tree = @repository.tree_entry("3dc532f", "vendor")
|
58
|
+
|
59
|
+
assert_equal({
|
72
60
|
:type => :submodule,
|
73
61
|
:filemode => 57344,
|
74
62
|
:name => "ui",
|
75
63
|
:oid => "d167e3e1c17a27e4cf459dd380670801b0659659",
|
76
64
|
:url => "git://gitorious.org/gitorious/ui3.git"
|
77
65
|
}, tree.entries.first)
|
78
|
-
done!
|
79
|
-
end
|
80
|
-
wait!
|
81
66
|
end
|
82
67
|
|
83
|
-
it "
|
84
|
-
@repository.tree_entry("3dc532f", "Gemfile")
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
89
|
-
wait!
|
68
|
+
it "returns blob" do
|
69
|
+
blob = @repository.tree_entry("3dc532f", "Gemfile")
|
70
|
+
|
71
|
+
assert blob.is_a?(Rugged::Blob)
|
72
|
+
assert_equal "source \"http://rubygems.org\"\n\ngemspec\n", blob.content
|
90
73
|
end
|
91
74
|
end
|
92
75
|
|
93
76
|
describe "#blame" do
|
94
|
-
it "returns
|
95
|
-
|
96
|
-
assert
|
97
|
-
assert deferrable.respond_to?(:errback)
|
98
|
-
end
|
99
|
-
|
100
|
-
it "yields blame" do
|
101
|
-
@repository.blame("master", "Gemfile").callback do |blame|
|
102
|
-
assert Dolt::Git::Blame === blame
|
103
|
-
done!
|
104
|
-
end
|
105
|
-
wait!
|
77
|
+
it "returns blame" do
|
78
|
+
blame = @repository.blame("master", "Gemfile")
|
79
|
+
assert Dolt::Git::Blame === blame
|
106
80
|
end
|
107
81
|
|
108
82
|
it "separates tree-like and path" do
|
109
|
-
|
110
|
-
|
111
|
-
@repository.blame("master", "Gemfile")
|
83
|
+
cmd = "git --git-dir #{@repository.path} blame -l -t -p master -- Gemfile"
|
84
|
+
Dolt::Git.expects(:shell).with(cmd).returns(Dolt::FakeProcess.new(0))
|
85
|
+
@repository.blame("master", "Gemfile")
|
86
|
+
end
|
112
87
|
|
113
|
-
|
88
|
+
it "does not allow injecting evil commands" do
|
89
|
+
cmd = "git --git-dir #{@repository.path} blame -l -t -p master -- Gemfile\\; rm -fr /tmp"
|
90
|
+
Dolt::Git.expects(:shell).with(cmd).returns(Dolt::FakeProcess.new(0))
|
91
|
+
@repository.blame("master", "Gemfile; rm -fr /tmp")
|
114
92
|
end
|
115
93
|
end
|
116
94
|
|
117
95
|
describe "#log" do
|
118
|
-
it "returns
|
119
|
-
|
120
|
-
|
121
|
-
assert
|
122
|
-
end
|
123
|
-
|
124
|
-
it "yields commits" do
|
125
|
-
@repository.log("master", "dolt.gemspec", 2).callback do |log|
|
126
|
-
assert_equal 2, log.length
|
127
|
-
assert Hash === log[0]
|
128
|
-
done!
|
129
|
-
end
|
130
|
-
wait!
|
96
|
+
it "returns commits" do
|
97
|
+
log = @repository.log("master", "dolt.gemspec", 2)
|
98
|
+
assert_equal 2, log.length
|
99
|
+
assert Hash === log[0]
|
131
100
|
end
|
132
101
|
end
|
133
102
|
|
134
103
|
describe "#tree_history" do
|
135
|
-
it "returns deferrable" do
|
136
|
-
deferrable = @repository.tree_history("master", "")
|
137
|
-
assert deferrable.respond_to?(:callback)
|
138
|
-
assert deferrable.respond_to?(:errback)
|
139
|
-
end
|
140
|
-
|
141
104
|
it "fails if path is not a tree" do
|
142
|
-
|
143
|
-
|
105
|
+
assert_raises Exception do |err|
|
106
|
+
tree = @repository.tree_history("master", "Gemfile")
|
144
107
|
assert_match /not a tree/, err.message
|
145
|
-
done!
|
146
108
|
end
|
147
|
-
wait!
|
148
109
|
end
|
149
110
|
|
150
111
|
it "fails if path does not exist in ref" do
|
151
|
-
|
152
|
-
|
112
|
+
assert_raises Rugged::IndexerError do |err|
|
113
|
+
tree = @repository.tree_history("26139a3", "test")
|
153
114
|
assert_match /does not exist/, err.message
|
154
|
-
done!
|
155
115
|
end
|
156
|
-
wait!
|
157
116
|
end
|
158
117
|
|
159
|
-
it "
|
160
|
-
|
161
|
-
promise.callback do |log|
|
162
|
-
assert_equal 11, log.length
|
163
|
-
expected = {
|
164
|
-
:type => :blob,
|
165
|
-
:oid => "e90021f89616ddf86855d05337c188408d3b417e",
|
166
|
-
:filemode => 33188,
|
167
|
-
:name => ".gitmodules",
|
168
|
-
:history => [{
|
169
|
-
:oid => "906d67b4f3e5de7364ba9b57d174d8998d53ced6",
|
170
|
-
:author => { :name => "Christian Johansen",
|
171
|
-
:email => "christian@cjohansen.no" },
|
172
|
-
:summary => "Working Moron server for viewing blobs",
|
173
|
-
:date => Time.parse("Mon Sep 10 15:07:39 +0200 2012"),
|
174
|
-
:message => ""
|
175
|
-
}]
|
176
|
-
}
|
118
|
+
it "returns tree with history" do
|
119
|
+
log = @repository.tree_history("48ffbf7", "")
|
177
120
|
|
178
|
-
|
179
|
-
|
180
|
-
|
121
|
+
assert_equal 11, log.length
|
122
|
+
expected = {
|
123
|
+
:type => :blob,
|
124
|
+
:oid => "e90021f89616ddf86855d05337c188408d3b417e",
|
125
|
+
:filemode => 33188,
|
126
|
+
:name => ".gitmodules",
|
127
|
+
:history => [{
|
128
|
+
:oid => "906d67b4f3e5de7364ba9b57d174d8998d53ced6",
|
129
|
+
:author => { :name => "Christian Johansen",
|
130
|
+
:email => "christian@cjohansen.no" },
|
131
|
+
:summary => "Working Moron server for viewing blobs",
|
132
|
+
:date => Time.parse("Mon Sep 10 15:07:39 +0200 2012"),
|
133
|
+
:message => ""
|
134
|
+
}]
|
135
|
+
}
|
181
136
|
|
182
|
-
|
183
|
-
puts "FAILED! #{err.inspect}"
|
184
|
-
end
|
185
|
-
|
186
|
-
wait!
|
137
|
+
assert_equal expected, log[0]
|
187
138
|
end
|
188
139
|
|
189
|
-
it "
|
190
|
-
|
140
|
+
it "returns nested tree with history" do
|
141
|
+
log = @repository.tree_history("48ffbf7", "lib")
|
191
142
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
assert_equal expected, log
|
208
|
-
done!
|
209
|
-
end
|
210
|
-
|
211
|
-
promise.errback do |err|
|
212
|
-
puts "FAILED! #{err.inspect}"
|
213
|
-
end
|
214
|
-
|
215
|
-
wait!
|
143
|
+
expected = [{
|
144
|
+
:type => :tree,
|
145
|
+
:oid => "58f84405b588699b24c619aa4cd83669c5623f88",
|
146
|
+
:filemode => 16384,
|
147
|
+
:name => "dolt",
|
148
|
+
:history => [{
|
149
|
+
:oid => "8ab4f8c42511f727244a02aeee04824891610bbd",
|
150
|
+
:author => { :name => "Christian Johansen",
|
151
|
+
:email => "christian@gitorious.com" },
|
152
|
+
:summary => "New version",
|
153
|
+
:date => Time.parse("Mon Oct 1 16:34:00 +0200 2012"),
|
154
|
+
:message => ""
|
155
|
+
}]
|
156
|
+
}]
|
157
|
+
assert_equal expected, log
|
216
158
|
end
|
217
159
|
end
|
218
160
|
|
219
161
|
describe "#readme" do
|
220
|
-
it "returns
|
221
|
-
deferrable = @repository.readme("master")
|
222
|
-
assert deferrable.respond_to?(:callback)
|
223
|
-
assert deferrable.respond_to?(:errback)
|
224
|
-
end
|
225
|
-
|
226
|
-
it "yields single readme" do
|
162
|
+
it "returns single readme" do
|
227
163
|
def @repository.tree(ref, path)
|
228
164
|
entries = [{ :type => :blob, :name => "Readme" },
|
229
165
|
{ :type => :blob, :name => "file.txt" },
|
230
166
|
{ :type => :tree, :name => "dir" }]
|
231
167
|
if ref == "master" && path == ""
|
232
|
-
|
168
|
+
OpenStruct.new(:entries => entries)
|
233
169
|
else
|
234
|
-
|
170
|
+
raise Exception.new("Wrong ref/path")
|
235
171
|
end
|
236
172
|
end
|
237
173
|
|
238
|
-
@repository.readme("master")
|
239
|
-
assert_equal 1, readmes.length
|
240
|
-
assert_equal "Readme", readmes.first[:name]
|
241
|
-
done!
|
242
|
-
end
|
174
|
+
readmes = @repository.readme("master")
|
243
175
|
|
244
|
-
|
176
|
+
assert_equal 1, readmes.length
|
177
|
+
assert_equal "Readme", readmes.first[:name]
|
245
178
|
end
|
246
179
|
|
247
|
-
it "does not
|
180
|
+
it "does not return trees" do
|
248
181
|
def @repository.tree(ref, path)
|
249
182
|
entries = [{ :type => :tree, :name => "Readme" },
|
250
183
|
{ :type => :blob, :name => "file.txt" },
|
251
184
|
{ :type => :tree, :name => "dir" }]
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
@repository.readme("master").callback do |readmes|
|
256
|
-
assert_equal 0, readmes.length
|
257
|
-
done!
|
185
|
+
OpenStruct.new(:entries => entries)
|
258
186
|
end
|
259
187
|
|
260
|
-
|
188
|
+
readmes = @repository.readme("master")
|
189
|
+
assert_equal 0, readmes.length
|
261
190
|
end
|
262
191
|
|
263
|
-
it "
|
192
|
+
it "returns all readmes" do
|
264
193
|
def @repository.tree(ref, path)
|
265
194
|
entries = [{ :type => :blob, :name => "Readme.rdoc" },
|
266
195
|
{ :type => :blob, :name => "readme" },
|
267
196
|
{ :type => :blob, :name => "Readme.md" }]
|
268
|
-
|
197
|
+
OpenStruct.new(:entries => entries)
|
269
198
|
end
|
270
199
|
|
271
|
-
@repository.readme("master")
|
272
|
-
|
273
|
-
done!
|
274
|
-
end
|
275
|
-
|
276
|
-
wait!
|
200
|
+
readmes = @repository.readme("master")
|
201
|
+
assert_equal 3, readmes.length
|
277
202
|
end
|
278
203
|
|
279
|
-
it "
|
204
|
+
it "returns empty array of readmes when looking up tree fails" do
|
280
205
|
def @repository.tree(ref, path)
|
281
|
-
|
282
|
-
end
|
283
|
-
|
284
|
-
@repository.readme("master").callback do |readmes|
|
285
|
-
assert_equal 0, readmes.length
|
286
|
-
done!
|
206
|
+
raise Exception.new("Unknown reason")
|
287
207
|
end
|
288
208
|
|
289
|
-
|
209
|
+
readmes = @repository.readme("master")
|
210
|
+
assert_equal 0, readmes.length
|
290
211
|
end
|
291
212
|
end
|
292
213
|
end
|