autobuild 1.10.0.b4 → 1.10.0.rc1
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.
- checksums.yaml +4 -4
- data/.gitattributes +1 -0
- data/.gitignore +5 -0
- data/.travis.yml +5 -0
- data/Changes.txt +8 -0
- data/Gemfile +3 -0
- data/README.md +54 -0
- data/Rakefile +7 -22
- data/autobuild.gemspec +30 -0
- data/lib/autobuild/environment.rb +27 -4
- data/lib/autobuild/import/archive.rb +5 -9
- data/lib/autobuild/import/git.rb +6 -8
- data/lib/autobuild/importer.rb +67 -0
- data/lib/autobuild/reporting.rb +7 -5
- data/lib/autobuild/test.rb +2 -14
- data/lib/autobuild/version.rb +1 -1
- data/manifest.xml +21 -0
- metadata +67 -48
- data/.gemtest +0 -0
- data/README.txt +0 -181
- data/TODO +0 -9
- data/test/data/cvsroot.tar +0 -0
- data/test/data/gitrepo-with-extra-commit-and-tag.tar +0 -0
- data/test/data/gitrepo.tar +0 -0
- data/test/data/svnroot.tar +0 -0
- data/test/data/tarimport.tar.gz +0 -0
- data/test/import/test_cvs.rb +0 -51
- data/test/import/test_git.rb +0 -446
- data/test/import/test_svn.rb +0 -144
- data/test/import/test_tar.rb +0 -95
- data/test/suite.rb +0 -7
- data/test/test_config.rb +0 -79
- data/test/test_environment.rb +0 -88
- data/test/test_reporting.rb +0 -43
- data/test/test_subcommand.rb +0 -38
data/test/import/test_cvs.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'autobuild/test'
|
2
|
-
|
3
|
-
class TC_CVSImport < Minitest::Test
|
4
|
-
include Autobuild
|
5
|
-
|
6
|
-
def setup
|
7
|
-
super
|
8
|
-
Autobuild.logdir = "#{tempdir}/log"
|
9
|
-
FileUtils.mkdir_p(Autobuild.logdir)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_cvs
|
13
|
-
Autobuild.verbose = true
|
14
|
-
untar('cvsroot.tar')
|
15
|
-
cvsroot = File.join(tempdir, 'cvsroot')
|
16
|
-
pkg_cvs = Package.new 'cvs'
|
17
|
-
pkg_cvs.srcdir = File.join(tempdir, 'cvs')
|
18
|
-
|
19
|
-
# Make a checkout
|
20
|
-
importer = Autobuild.cvs(cvsroot, module: 'cvs')
|
21
|
-
importer.import(pkg_cvs)
|
22
|
-
assert( File.exists?(File.join(pkg_cvs.srcdir, 'test')) )
|
23
|
-
|
24
|
-
# Make an update
|
25
|
-
importer.import(pkg_cvs)
|
26
|
-
|
27
|
-
# Make an update fail because the repository does not exist anymore
|
28
|
-
FileUtils.rm_rf cvsroot
|
29
|
-
assert_raises(Autobuild::SubcommandFailed) { importer.import pkg_cvs }
|
30
|
-
|
31
|
-
# Make a checkout fail because the repository does not exist anymore
|
32
|
-
FileUtils.rm_rf pkg_cvs.srcdir
|
33
|
-
assert_raises(Autobuild::SubcommandFailed) { importer.import pkg_cvs }
|
34
|
-
|
35
|
-
# Recreate the repository, and make a checkout fail because the
|
36
|
-
# WC is not a CVS WC
|
37
|
-
untar('cvsroot.tar')
|
38
|
-
FileUtils.mkdir pkg_cvs.srcdir
|
39
|
-
assert_raises(Autobuild::ConfigException) { importer.import pkg_cvs }
|
40
|
-
|
41
|
-
# Create two repositories, and make the update fail because the
|
42
|
-
# WC is of the wrong source
|
43
|
-
FileUtils.rm_rf pkg_cvs.srcdir
|
44
|
-
importer.import(pkg_cvs)
|
45
|
-
FileUtils.mv cvsroot, "#{cvsroot}.2"
|
46
|
-
importer = Autobuild.cvs("#{cvsroot}.2", module: 'cvs')
|
47
|
-
assert_raises(Autobuild::ConfigException) { importer.import pkg_cvs }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
data/test/import/test_git.rb
DELETED
@@ -1,446 +0,0 @@
|
|
1
|
-
require 'autobuild/test'
|
2
|
-
|
3
|
-
describe Autobuild::Git do
|
4
|
-
attr_reader :pkg, :importer, :gitrepo
|
5
|
-
before do
|
6
|
-
untar('gitrepo.tar')
|
7
|
-
@gitrepo = File.join(tempdir, 'gitrepo.git')
|
8
|
-
@pkg = Autobuild::Package.new 'test'
|
9
|
-
pkg.srcdir = File.join(tempdir, 'git')
|
10
|
-
@importer = Autobuild.git(gitrepo)
|
11
|
-
pkg.importer = importer
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#initialize" do
|
15
|
-
it "allows passing the branch as second argument for backward-compatibility way" do
|
16
|
-
Autobuild.silent = true
|
17
|
-
importer = Autobuild::Git.new('repo', 'branch', tag: 'test')
|
18
|
-
assert_equal 'branch', importer.branch
|
19
|
-
end
|
20
|
-
it "raises ConfigException if the branch parameter and the branch options are both given" do
|
21
|
-
Autobuild.silent = true
|
22
|
-
assert_raises(Autobuild::ConfigException) do
|
23
|
-
Autobuild::Git.new('repo', 'branch', branch: 'another')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "version_compare" do
|
29
|
-
it "should return -1 if the actual version is greater" do
|
30
|
-
assert_equal(-1, Autobuild::Git.compare_versions([2, 1, 0], [2, 0, 1]))
|
31
|
-
end
|
32
|
-
it "should return 0 if the versions are equal" do
|
33
|
-
assert_equal(0, Autobuild::Git.compare_versions([2, 1, 0], [2, 1, 0]))
|
34
|
-
end
|
35
|
-
it "should return 1 if the required version is greater" do
|
36
|
-
assert_equal(1, Autobuild::Git.compare_versions([2, 0, 1], [2, 1, 0]))
|
37
|
-
assert_equal(1, Autobuild::Git.compare_versions([1, 9, 1], [2, 1, 0]))
|
38
|
-
end
|
39
|
-
it "should fill missing version parts with zeros" do
|
40
|
-
assert_equal(-1, Autobuild::Git.compare_versions([2, 1], [2, 0, 1]))
|
41
|
-
assert_equal(-1, Autobuild::Git.compare_versions([2, 1, 0], [2, 0]))
|
42
|
-
assert_equal(0, Autobuild::Git.compare_versions([2, 1], [2, 1, 0]))
|
43
|
-
assert_equal(0, Autobuild::Git.compare_versions([2, 1, 0], [2, 1]))
|
44
|
-
assert_equal(1, Autobuild::Git.compare_versions([2, 1], [2, 1, 1]))
|
45
|
-
assert_equal(1, Autobuild::Git.compare_versions([2, 1, 1], [2, 2]))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "at_least_version" do
|
50
|
-
Autobuild::Git.stub :version, [1,9,1] do
|
51
|
-
it "should be true if required version is smaller" do
|
52
|
-
assert_equal( true, Autobuild::Git.at_least_version( 1,8,1 ) )
|
53
|
-
end
|
54
|
-
it "should be false if required version is greater" do
|
55
|
-
assert_equal( false, Autobuild::Git.at_least_version( 50,0,1 ) )
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#has_commit?" do
|
61
|
-
before do
|
62
|
-
importer.import(pkg)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns true if the specified name resolves to a commit" do
|
66
|
-
assert importer.has_commit?(pkg, importer.rev_parse(pkg, 'HEAD'))
|
67
|
-
end
|
68
|
-
it "returns true if the specified commit is present locally" do
|
69
|
-
assert importer.has_commit?(pkg, importer.rev_parse(pkg, '8b09cb0febae222b31e2ee55f839c1e00dc7edc4'))
|
70
|
-
end
|
71
|
-
it "returns false if the specified name does not resolve to an object" do
|
72
|
-
assert !importer.has_commit?(pkg, 'blabla')
|
73
|
-
end
|
74
|
-
it "returns false if the specified commit is not present locally" do
|
75
|
-
assert !importer.has_commit?(pkg, 'c8cf0798b1d53931314a86bdb3e2ad874eb8deb5')
|
76
|
-
end
|
77
|
-
it "raises for any other error" do
|
78
|
-
flexmock(Autobuild::Subprocess).should_receive(:run).
|
79
|
-
and_raise(Autobuild::SubcommandFailed.new('test', 'test', 'bla', 200))
|
80
|
-
assert_raises(Autobuild::SubcommandFailed) do
|
81
|
-
importer.has_commit?(pkg, 'master')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "#has_branch?" do
|
87
|
-
before do
|
88
|
-
importer.import(pkg)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "returns true if the branch exists" do
|
92
|
-
assert importer.has_branch?(pkg, 'master')
|
93
|
-
end
|
94
|
-
|
95
|
-
it "returns false if the branch does not exist" do
|
96
|
-
assert !importer.has_branch?(pkg, 'does_not_exist')
|
97
|
-
end
|
98
|
-
|
99
|
-
it "raises for any other error" do
|
100
|
-
flexmock(Autobuild::Subprocess).should_receive(:run).
|
101
|
-
and_raise(Autobuild::SubcommandFailed.new('test', 'test', 'bla', 200))
|
102
|
-
assert_raises(Autobuild::SubcommandFailed) do
|
103
|
-
importer.has_branch?(pkg, 'master')
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "#detached_head?" do
|
109
|
-
before do
|
110
|
-
importer.import(pkg)
|
111
|
-
end
|
112
|
-
|
113
|
-
it "returns true if HEAD is detached" do
|
114
|
-
importer.run_git(pkg, 'checkout', 'master~1')
|
115
|
-
assert importer.detached_head?(pkg)
|
116
|
-
end
|
117
|
-
it "returns false if HEAD is pointing to a branch" do
|
118
|
-
assert !importer.detached_head?(pkg)
|
119
|
-
end
|
120
|
-
it "raises for any other error" do
|
121
|
-
flexmock(Autobuild::Subprocess).should_receive(:run).
|
122
|
-
and_raise(Autobuild::SubcommandFailed.new('test', 'test', 'bla', 200))
|
123
|
-
assert_raises(Autobuild::SubcommandFailed) do
|
124
|
-
importer.detached_head?(pkg)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "#current_branch" do
|
130
|
-
before do
|
131
|
-
importer.import(pkg)
|
132
|
-
end
|
133
|
-
|
134
|
-
it "returns the current branch name" do
|
135
|
-
importer.run_git(pkg, 'checkout', '-b', 'test')
|
136
|
-
assert_equal 'refs/heads/test', importer.current_branch(pkg)
|
137
|
-
end
|
138
|
-
it "returns nil if the head is detached" do
|
139
|
-
importer.run_git(pkg, 'checkout', 'master~1')
|
140
|
-
assert importer.current_branch(pkg).nil?
|
141
|
-
end
|
142
|
-
it "raises for any other error" do
|
143
|
-
flexmock(Autobuild::Subprocess).should_receive(:run).
|
144
|
-
and_raise(Autobuild::SubcommandFailed.new('test', 'test', 'bla', 200))
|
145
|
-
assert_raises(Autobuild::SubcommandFailed) do
|
146
|
-
importer.current_branch(pkg)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe "#rev_parse" do
|
152
|
-
it "raises PackageException if the name does not exist" do
|
153
|
-
importer.import(pkg)
|
154
|
-
assert_raises(Autobuild::PackageException) do
|
155
|
-
importer.rev_parse(pkg, 'does_not_exist')
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "#show" do
|
161
|
-
it "returns the content of a path at a commit" do
|
162
|
-
importer.import(pkg)
|
163
|
-
File.open(File.join(tempdir, 'git', 'test'), 'a') do |io|
|
164
|
-
io.puts "newline"
|
165
|
-
end
|
166
|
-
head = importer.rev_parse(pkg, 'HEAD')
|
167
|
-
importer.run_git(pkg, 'commit', '-a', '-m', 'test commit')
|
168
|
-
assert_equal '', importer.show(pkg, head, 'test')
|
169
|
-
assert_equal 'newline', importer.show(pkg, 'HEAD', 'test')
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe ".has_uncommitted_changes?" do
|
174
|
-
before do
|
175
|
-
importer.import(pkg)
|
176
|
-
end
|
177
|
-
|
178
|
-
it "returns true if some files is modified" do
|
179
|
-
File.open(File.join(tempdir, 'git', 'test'), 'a') do |io|
|
180
|
-
io.puts "newline"
|
181
|
-
end
|
182
|
-
assert Autobuild::Git.has_uncommitted_changes?(pkg)
|
183
|
-
end
|
184
|
-
it "returns true if some files is modified and staged" do
|
185
|
-
file = File.join(tempdir, 'git', 'test')
|
186
|
-
File.open(file, 'a') { |io| io.puts "newline" }
|
187
|
-
importer.run_git(pkg, 'add', file)
|
188
|
-
assert Autobuild::Git.has_uncommitted_changes?(pkg)
|
189
|
-
end
|
190
|
-
it "returns true if a new file is added" do
|
191
|
-
newfile = File.join(tempdir, 'git', 'blabla')
|
192
|
-
FileUtils.touch newfile
|
193
|
-
importer.run_git(pkg, 'add', newfile)
|
194
|
-
assert Autobuild::Git.has_uncommitted_changes?(pkg)
|
195
|
-
end
|
196
|
-
it "returns true if a file has been removed" do
|
197
|
-
FileUtils.rm_f File.join(tempdir, 'git', 'test')
|
198
|
-
assert Autobuild::Git.has_uncommitted_changes?(pkg)
|
199
|
-
end
|
200
|
-
it "returns true if a file has been removed and staged" do
|
201
|
-
delfile = File.join(tempdir, 'git', 'test')
|
202
|
-
FileUtils.rm_f delfile
|
203
|
-
importer.run_git(pkg, 'rm', delfile)
|
204
|
-
assert Autobuild::Git.has_uncommitted_changes?(pkg)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
describe "#commit_present_in?" do
|
209
|
-
attr_reader :commits
|
210
|
-
before do
|
211
|
-
importer.import(pkg)
|
212
|
-
@commits = [
|
213
|
-
importer.rev_parse(pkg, 'HEAD'),
|
214
|
-
importer.rev_parse(pkg, 'HEAD~1')]
|
215
|
-
end
|
216
|
-
|
217
|
-
it "returns true if the revision is in the provided branch" do
|
218
|
-
assert importer.commit_present_in?(pkg, 'HEAD', 'master')
|
219
|
-
assert importer.commit_present_in?(pkg, commits[0], 'master')
|
220
|
-
assert importer.commit_present_in?(pkg, 'HEAD~1', 'master')
|
221
|
-
assert importer.commit_present_in?(pkg, commits[1], 'master')
|
222
|
-
end
|
223
|
-
it "returns false if the revision is not in the provided branch" do
|
224
|
-
importer.run_git(pkg, 'branch', 'fork', 'autobuild/fork')
|
225
|
-
assert !importer.commit_present_in?(pkg, commits[0], "refs/heads/fork")
|
226
|
-
end
|
227
|
-
# git rev-parse return the tag ID for annotated tags instead of the
|
228
|
-
# commit ID. This was in turn breaking commit_present_in?
|
229
|
-
it "handles annotated tags properly" do
|
230
|
-
importer.run_git(pkg, 'tag', '-a', '-m', 'tag0', "tag0", "HEAD~1")
|
231
|
-
assert importer.commit_present_in?(pkg, 'tag0', 'master')
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
describe "update" do
|
236
|
-
def self.common_commit_and_tag_behaviour
|
237
|
-
it "does not access the repository if the target is already merged and reset is false" do
|
238
|
-
importer.import(pkg)
|
239
|
-
|
240
|
-
# We relocate to a non-existing repository to ensure that it
|
241
|
-
# does not try to access it
|
242
|
-
importer.relocate('/does/not/exist')
|
243
|
-
pin_importer('tip~1')
|
244
|
-
importer.import(pkg, reset: false)
|
245
|
-
assert_on_commit "tip"
|
246
|
-
end
|
247
|
-
it "does not access the repository if the target is already HEAD and reset is true" do
|
248
|
-
importer.import(pkg)
|
249
|
-
pin_importer('tip')
|
250
|
-
importer.relocate('/does/not/exist')
|
251
|
-
importer.import(pkg, reset: true)
|
252
|
-
assert_on_commit "tip"
|
253
|
-
end
|
254
|
-
it "does not access the remote repository if the commit is present locally" do
|
255
|
-
pin_importer('tip~1')
|
256
|
-
importer.import(pkg)
|
257
|
-
pin_importer('tip')
|
258
|
-
importer.relocate('/does/not/exist')
|
259
|
-
importer.import(pkg, reset: false)
|
260
|
-
assert_on_commit "tip"
|
261
|
-
end
|
262
|
-
it "attempts to merge the target commit if it is not present in HEAD" do
|
263
|
-
pin_importer('tip~1')
|
264
|
-
importer.import(pkg)
|
265
|
-
pin_importer('tip')
|
266
|
-
importer.import(pkg, reset: false)
|
267
|
-
assert_on_commit "tip"
|
268
|
-
end
|
269
|
-
it "resets if reset is true" do
|
270
|
-
importer.import(pkg)
|
271
|
-
pin_importer('tip~1')
|
272
|
-
importer.import(pkg, reset: true)
|
273
|
-
assert_on_commit "tip~1"
|
274
|
-
end
|
275
|
-
it "refuses to reset if some commits are present locally but not in the remote branch" do
|
276
|
-
importer.import(pkg)
|
277
|
-
File.open(File.join(tempdir, 'git', 'test3'), 'w') do |io|
|
278
|
-
io.puts "test"
|
279
|
-
end
|
280
|
-
importer.run_git(pkg, 'add', 'test3')
|
281
|
-
importer.run_git(pkg, 'commit', '-a', '-m', 'third commit')
|
282
|
-
current_head = importer.rev_parse(pkg, 'HEAD')
|
283
|
-
pin_importer('tip~1')
|
284
|
-
assert_raises(Autobuild::ImporterCannotReset) do
|
285
|
-
importer.import(pkg, reset: true)
|
286
|
-
end
|
287
|
-
assert_equal current_head, importer.rev_parse(pkg, 'HEAD')
|
288
|
-
end
|
289
|
-
it "creates the local branch at the specified commit if the branch does not exist" do
|
290
|
-
importer.import(pkg)
|
291
|
-
head = importer.rev_parse(pkg, 'HEAD')
|
292
|
-
importer.local_branch = 'local'
|
293
|
-
importer.import(pkg)
|
294
|
-
assert_equal 'refs/heads/local', importer.current_branch(pkg)
|
295
|
-
assert_equal head, importer.rev_parse(pkg, 'HEAD')
|
296
|
-
end
|
297
|
-
|
298
|
-
it "acts on local_branch" do
|
299
|
-
importer.import(pkg)
|
300
|
-
head = importer.rev_parse(pkg, 'HEAD')
|
301
|
-
importer.run_git(pkg, 'reset', '--hard', 'master~1')
|
302
|
-
importer.run_git(pkg, 'branch', 'local')
|
303
|
-
importer.local_branch = 'local'
|
304
|
-
importer.import(pkg)
|
305
|
-
assert_equal 'refs/heads/local', importer.current_branch(pkg)
|
306
|
-
assert_equal head, importer.rev_parse(pkg, 'refs/remotes/autobuild/master')
|
307
|
-
end
|
308
|
-
|
309
|
-
it "refuses to update if the local and remote branches have diverged" do
|
310
|
-
importer.import(pkg)
|
311
|
-
importer.run_git(pkg, 'reset', '--hard', 'master~1')
|
312
|
-
File.open(File.join(tempdir, 'git', 'test'), 'a') do |io|
|
313
|
-
io.puts "test"
|
314
|
-
end
|
315
|
-
importer.run_git(pkg, 'commit', '-a', '-m', 'a fork commit')
|
316
|
-
assert_raises(Autobuild::PackageException) do
|
317
|
-
importer.import(pkg)
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
it "switches to the local branch regardless of the presence of the tag or commit" do
|
322
|
-
importer.import(pkg)
|
323
|
-
head = importer.rev_parse(pkg, 'HEAD')
|
324
|
-
importer.run_git(pkg, 'reset', '--hard', 'master~1')
|
325
|
-
importer.run_git(pkg, 'branch', 'local')
|
326
|
-
importer.local_branch = 'local'
|
327
|
-
importer.relocate(importer.repository, tag: 'third_commit')
|
328
|
-
importer.update(pkg)
|
329
|
-
assert_equal 'refs/heads/local', importer.current_branch(pkg)
|
330
|
-
assert_equal head, importer.rev_parse(pkg, 'refs/remotes/autobuild/master')
|
331
|
-
end
|
332
|
-
|
333
|
-
describe "the reset behaviour" do
|
334
|
-
it "checks out the local branch even if its original state was diverged from the current commit" do
|
335
|
-
pin_importer 'fork'
|
336
|
-
importer.import(pkg)
|
337
|
-
assert_on_commit 'fork'
|
338
|
-
end
|
339
|
-
it "resets the local branch even if it diverged from the current commit" do
|
340
|
-
importer.import(pkg)
|
341
|
-
pin_importer 'fork'
|
342
|
-
importer.import(pkg, reset: true)
|
343
|
-
assert_on_commit 'fork'
|
344
|
-
end
|
345
|
-
it "refuses to reset the local branch if HEAD is not present remotely" do
|
346
|
-
importer.import(pkg)
|
347
|
-
File.open(File.join(tempdir, 'git', 'test'), 'a') do |io|
|
348
|
-
io.puts "test"
|
349
|
-
end
|
350
|
-
importer.run_git(pkg, 'commit', '-a', '-m', 'a fork commit')
|
351
|
-
new_head = importer.rev_parse(pkg, 'HEAD')
|
352
|
-
pin_importer 'fork'
|
353
|
-
assert_raises(Autobuild::ImporterCannotReset) do
|
354
|
-
importer.import(pkg, reset: true)
|
355
|
-
end
|
356
|
-
assert_equal new_head, importer.rev_parse(pkg, 'HEAD')
|
357
|
-
end
|
358
|
-
it "cleanly resets to the start state if local changes make the checkout abort" do
|
359
|
-
importer.import(pkg)
|
360
|
-
File.open(File.join(tempdir, 'git', 'test'), 'a') do |io|
|
361
|
-
io.puts "test"
|
362
|
-
end
|
363
|
-
pin_importer 'fork'
|
364
|
-
assert_raises(Autobuild::SubcommandFailed) do
|
365
|
-
importer.import(pkg, reset: true)
|
366
|
-
end
|
367
|
-
assert_on_commit 'tip'
|
368
|
-
end
|
369
|
-
end
|
370
|
-
end
|
371
|
-
describe "with a specific commit given" do
|
372
|
-
def assert_on_commit(id)
|
373
|
-
assert_equal commits[id], importer.rev_parse(pkg, 'HEAD')
|
374
|
-
end
|
375
|
-
def commits
|
376
|
-
if !@commits
|
377
|
-
importer = Autobuild.git(gitrepo)
|
378
|
-
pkg = Autobuild::Package.new 'commits'
|
379
|
-
pkg.srcdir = gitrepo
|
380
|
-
pkg.importer = importer
|
381
|
-
@commits = Hash[
|
382
|
-
'tip' => importer.rev_parse(pkg, 'master'),
|
383
|
-
'tip~1' => importer.rev_parse(pkg, 'master~1'),
|
384
|
-
'fork' => importer.rev_parse(pkg, 'fork'),
|
385
|
-
]
|
386
|
-
end
|
387
|
-
@commits
|
388
|
-
end
|
389
|
-
|
390
|
-
def pin_importer(id, options = Hash.new)
|
391
|
-
importer.relocate(importer.repository, options.merge(commit: commits[id]))
|
392
|
-
end
|
393
|
-
|
394
|
-
it "fetches from the remote repository if the commit is not present locally" do
|
395
|
-
untar('gitrepo-with-extra-commit-and-tag.tar')
|
396
|
-
importer.import(pkg)
|
397
|
-
extra_repo = File.join(tempdir, 'gitrepo-with-extra-commit-and-tag.git')
|
398
|
-
importer.relocate(extra_repo, commit: '1ddb20665622279700770be09f9a291b37c9b631')
|
399
|
-
importer.import(pkg, reset: false)
|
400
|
-
assert_equal '1ddb20665622279700770be09f9a291b37c9b631', importer.rev_parse(pkg, 'HEAD')
|
401
|
-
end
|
402
|
-
|
403
|
-
common_commit_and_tag_behaviour
|
404
|
-
end
|
405
|
-
describe "with a specific tag given" do
|
406
|
-
attr_reader :commits
|
407
|
-
|
408
|
-
before do
|
409
|
-
importer = Autobuild.git(gitrepo)
|
410
|
-
pkg = Autobuild::Package.new 'commits'
|
411
|
-
pkg.srcdir = gitrepo
|
412
|
-
pkg.importer = importer
|
413
|
-
importer.run_git_bare(pkg, 'tag', "tag0", "refs/heads/master")
|
414
|
-
importer.run_git_bare(pkg, 'tag', "tag1", "refs/heads/master~1")
|
415
|
-
importer.run_git_bare(pkg, 'tag', "forktag", "refs/heads/fork")
|
416
|
-
@pins = Hash['tip' => 'tag0', 'tip~1' => 'tag1', 'fork' => 'forktag']
|
417
|
-
@commits = Hash[
|
418
|
-
'tip' => importer.rev_parse(pkg, 'refs/heads/master'),
|
419
|
-
'tip~1' => importer.rev_parse(pkg, 'refs/heads/master~1'),
|
420
|
-
'fork' => importer.rev_parse(pkg, 'refs/heads/fork'),
|
421
|
-
]
|
422
|
-
end
|
423
|
-
|
424
|
-
def assert_on_commit(id)
|
425
|
-
assert_equal commits[id], importer.rev_parse(pkg, 'HEAD')
|
426
|
-
end
|
427
|
-
|
428
|
-
def pin_importer(id, options = Hash.new)
|
429
|
-
importer.relocate(importer.repository, options.merge(tag: @pins[id]))
|
430
|
-
end
|
431
|
-
|
432
|
-
it "fetches from the remote repository if the commit is not present locally" do
|
433
|
-
untar('gitrepo-with-extra-commit-and-tag.tar')
|
434
|
-
importer.import(pkg)
|
435
|
-
extra_repo = File.join(tempdir, 'gitrepo-with-extra-commit-and-tag.git')
|
436
|
-
importer.relocate(extra_repo, tag: 'third_commit')
|
437
|
-
importer.import(pkg, reset: false)
|
438
|
-
tag_id = importer.rev_parse(pkg, 'third_commit')
|
439
|
-
assert_equal tag_id, importer.rev_parse(pkg, 'HEAD')
|
440
|
-
end
|
441
|
-
|
442
|
-
common_commit_and_tag_behaviour
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|