autobuild 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +0 -3
- data/lib/autobuild/import/git.rb +28 -16
- data/lib/autobuild/version.rb +1 -1
- data/test/import/test_git.rb +67 -22
- metadata +2 -5
- data/test/data/gitrepo/test +0 -0
- data/test/data/gitrepo/test2 +0 -0
- data/test/data/gitrepo/test3 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d07251a9467505108e7d4ffa2a83480e77b4051
|
4
|
+
data.tar.gz: f9d440c442f763d121bb589810fb2e97210911c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11958c9d1bfa46c8d3abfe37dfe4e414f316b7e0162cafdcf0abda4228e27ed902b02bc2ff942ef42ba41996878a6c18eb38d82d2708b7ee2c808d073fd85a5b
|
7
|
+
data.tar.gz: 78b12476fd6c0a16573db0a46f6e4e500dd42da24fd8471440b5487ca00236f51e003afa5c56b8fd1a6d5b449ae4a04420e5e5f95b3c0ffeb816d654fa37423b
|
data/Manifest.txt
CHANGED
@@ -42,9 +42,6 @@ samples/openrobots.autobuild
|
|
42
42
|
test/data/cvsroot.tar
|
43
43
|
test/data/gitrepo-with-extra-commit-and-tag.tar
|
44
44
|
test/data/gitrepo.tar
|
45
|
-
test/data/gitrepo/test
|
46
|
-
test/data/gitrepo/test2
|
47
|
-
test/data/gitrepo/test3
|
48
45
|
test/data/svnroot.tar
|
49
46
|
test/data/tarimport.tar.gz
|
50
47
|
test/import/test_cvs.rb
|
data/lib/autobuild/import/git.rb
CHANGED
@@ -623,22 +623,36 @@ module Autobuild
|
|
623
623
|
end
|
624
624
|
end
|
625
625
|
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
626
|
+
# Safely resets the current branch to a given commit
|
627
|
+
#
|
628
|
+
# This method safely resets the current branch to a given commit,
|
629
|
+
# not requiring a clean working copy (i.e. it can handle local changes).
|
630
|
+
#
|
631
|
+
# It verifies that the current HEAD will not be lost by the operation,
|
632
|
+
# either because it is included in the target commit or because it is
|
633
|
+
# present remotely
|
634
|
+
#
|
635
|
+
# @param [Package] package the package we handle
|
636
|
+
# @param [String] target_commit the commit we want to reset HEAD to
|
637
|
+
# @param [String] fetch_commit the state of the remote branch. This is
|
638
|
+
# used to avoid losing commits if HEAD is not included in
|
639
|
+
# target_commit
|
640
|
+
def reset_head_to_commit(package, target_commit, fetch_commit)
|
641
|
+
current_head = rev_parse(package, 'HEAD')
|
642
|
+
head_to_target = merge_status(package, target_commit, current_head)
|
639
643
|
status_to_target = head_to_target.status
|
644
|
+
|
640
645
|
if status_to_target == Status::UP_TO_DATE
|
641
646
|
return
|
647
|
+
elsif status_to_target == Status::SIMPLE_UPDATE
|
648
|
+
run_git(package, 'merge', target_commit)
|
649
|
+
else
|
650
|
+
# Check whether the current HEAD is present on the remote
|
651
|
+
# repository. We'll refuse resetting if there are uncommitted
|
652
|
+
# changes
|
653
|
+
if !commit_present_in?(package, current_head, fetch_commit)
|
654
|
+
raise ImporterCannotReset.new(package, 'import'), "branch #{local_branch} of #{package.name} contains commits that do not seem to be present on the branch #{remote_branch} of the remote repository. I can't go on as it could make you loose some stuff. Update the remote branch in your overrides, push your changes or reset to the remote commit manually before trying again"
|
655
|
+
end
|
642
656
|
end
|
643
657
|
|
644
658
|
package.message " %%s: resetting branch %s to %s" % [local_branch, target_commit.to_s]
|
@@ -706,8 +720,6 @@ module Autobuild
|
|
706
720
|
if options[:reset]
|
707
721
|
if current_head == pinned_state
|
708
722
|
return
|
709
|
-
elsif merge_if_simple(package, pinned_state)
|
710
|
-
return
|
711
723
|
end
|
712
724
|
elsif commit_present_in?(package, pinned_state, current_head)
|
713
725
|
return
|
@@ -718,7 +730,7 @@ module Autobuild
|
|
718
730
|
|
719
731
|
fetch_commit ||= current_remote_commit(package, options[:only_local])
|
720
732
|
if options[:reset]
|
721
|
-
|
733
|
+
reset_head_to_commit(package, target_commit, fetch_commit)
|
722
734
|
else
|
723
735
|
merge_if_simple(package, target_commit)
|
724
736
|
end
|
data/lib/autobuild/version.rb
CHANGED
data/test/import/test_git.rb
CHANGED
@@ -240,37 +240,37 @@ describe Autobuild::Git do
|
|
240
240
|
# We relocate to a non-existing repository to ensure that it
|
241
241
|
# does not try to access it
|
242
242
|
importer.relocate('/does/not/exist')
|
243
|
-
pin_importer(1)
|
243
|
+
pin_importer('tip~1')
|
244
244
|
importer.import(pkg, reset: false)
|
245
|
-
assert_on_commit
|
245
|
+
assert_on_commit "tip"
|
246
246
|
end
|
247
247
|
it "does not access the repository if the target is already HEAD and reset is true" do
|
248
248
|
importer.import(pkg)
|
249
|
-
pin_importer(
|
249
|
+
pin_importer('tip')
|
250
250
|
importer.relocate('/does/not/exist')
|
251
251
|
importer.import(pkg, reset: true)
|
252
|
-
assert_on_commit
|
252
|
+
assert_on_commit "tip"
|
253
253
|
end
|
254
254
|
it "does not access the remote repository if the commit is present locally" do
|
255
|
-
pin_importer(1)
|
255
|
+
pin_importer('tip~1')
|
256
256
|
importer.import(pkg)
|
257
|
-
pin_importer(
|
257
|
+
pin_importer('tip')
|
258
258
|
importer.relocate('/does/not/exist')
|
259
259
|
importer.import(pkg, reset: false)
|
260
|
-
assert_on_commit
|
260
|
+
assert_on_commit "tip"
|
261
261
|
end
|
262
262
|
it "attempts to merge the target commit if it is not present in HEAD" do
|
263
|
-
pin_importer(1)
|
263
|
+
pin_importer('tip~1')
|
264
264
|
importer.import(pkg)
|
265
|
-
pin_importer(
|
265
|
+
pin_importer('tip')
|
266
266
|
importer.import(pkg, reset: false)
|
267
|
-
assert_on_commit
|
267
|
+
assert_on_commit "tip"
|
268
268
|
end
|
269
269
|
it "resets if reset is true" do
|
270
270
|
importer.import(pkg)
|
271
|
-
pin_importer(1)
|
271
|
+
pin_importer('tip~1')
|
272
272
|
importer.import(pkg, reset: true)
|
273
|
-
assert_on_commit 1
|
273
|
+
assert_on_commit "tip~1"
|
274
274
|
end
|
275
275
|
it "refuses to reset if some commits are present locally but not in the remote branch" do
|
276
276
|
importer.import(pkg)
|
@@ -280,7 +280,7 @@ describe Autobuild::Git do
|
|
280
280
|
importer.run_git(pkg, 'add', 'test3')
|
281
281
|
importer.run_git(pkg, 'commit', '-a', '-m', 'third commit')
|
282
282
|
current_head = importer.rev_parse(pkg, 'HEAD')
|
283
|
-
pin_importer(1)
|
283
|
+
pin_importer('tip~1')
|
284
284
|
assert_raises(Autobuild::ImporterCannotReset) do
|
285
285
|
importer.import(pkg, reset: true)
|
286
286
|
end
|
@@ -317,6 +317,7 @@ describe Autobuild::Git do
|
|
317
317
|
importer.import(pkg)
|
318
318
|
end
|
319
319
|
end
|
320
|
+
|
320
321
|
it "switches to the local branch regardless of the presence of the tag or commit" do
|
321
322
|
importer.import(pkg)
|
322
323
|
head = importer.rev_parse(pkg, 'HEAD')
|
@@ -328,6 +329,44 @@ describe Autobuild::Git do
|
|
328
329
|
assert_equal 'refs/heads/local', importer.current_branch(pkg)
|
329
330
|
assert_equal head, importer.rev_parse(pkg, 'refs/remotes/autobuild/master')
|
330
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
|
331
370
|
end
|
332
371
|
describe "with a specific commit given" do
|
333
372
|
def assert_on_commit(id)
|
@@ -339,9 +378,11 @@ describe Autobuild::Git do
|
|
339
378
|
pkg = Autobuild::Package.new 'commits'
|
340
379
|
pkg.srcdir = gitrepo
|
341
380
|
pkg.importer = importer
|
342
|
-
@commits = [
|
343
|
-
importer.rev_parse(pkg, '
|
344
|
-
importer.rev_parse(pkg, '
|
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
|
+
]
|
345
386
|
end
|
346
387
|
@commits
|
347
388
|
end
|
@@ -369,11 +410,15 @@ describe Autobuild::Git do
|
|
369
410
|
pkg = Autobuild::Package.new 'commits'
|
370
411
|
pkg.srcdir = gitrepo
|
371
412
|
pkg.importer = importer
|
372
|
-
importer.run_git_bare(pkg, 'tag', "tag0", "
|
373
|
-
importer.run_git_bare(pkg, 'tag', "tag1", "
|
374
|
-
|
375
|
-
|
376
|
-
|
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
|
+
]
|
377
422
|
end
|
378
423
|
|
379
424
|
def assert_on_commit(id)
|
@@ -381,7 +426,7 @@ describe Autobuild::Git do
|
|
381
426
|
end
|
382
427
|
|
383
428
|
def pin_importer(id, options = Hash.new)
|
384
|
-
importer.relocate(importer.repository, options.merge(tag:
|
429
|
+
importer.relocate(importer.repository, options.merge(tag: @pins[id]))
|
385
430
|
end
|
386
431
|
|
387
432
|
it "fetches from the remote repository if the commit is not present locally" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autobuild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Joyeux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -138,9 +138,6 @@ files:
|
|
138
138
|
- test/data/cvsroot.tar
|
139
139
|
- test/data/gitrepo-with-extra-commit-and-tag.tar
|
140
140
|
- test/data/gitrepo.tar
|
141
|
-
- test/data/gitrepo/test
|
142
|
-
- test/data/gitrepo/test2
|
143
|
-
- test/data/gitrepo/test3
|
144
141
|
- test/data/svnroot.tar
|
145
142
|
- test/data/tarimport.tar.gz
|
146
143
|
- test/import/test_cvs.rb
|
data/test/data/gitrepo/test
DELETED
File without changes
|
data/test/data/gitrepo/test2
DELETED
File without changes
|
data/test/data/gitrepo/test3
DELETED
File without changes
|