autobuild 1.9.0.b2 → 1.9.0.b3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a17e6033c3c9c0a0bf7ff4e8eeccbfcc777a914
4
- data.tar.gz: ee6480b0e089711f67ba08a4361a1bd283f7992b
3
+ metadata.gz: 97d91fdc5b06cf57bc85a29436b8ae83de8bf188
4
+ data.tar.gz: 366b4196e75cb245ba30e241d3b3b2d57b18919e
5
5
  SHA512:
6
- metadata.gz: cdbfc5c964b12cc5be90c9f18f8abc9264fa8a07296b75f323c751d3f2a1400bf0a98357f43eeaaed59a0d42313c3098926524adc32fc2d5ee852a2ddf143b7f
7
- data.tar.gz: 247a8bbc07a21967916caf4c74b5daba7abfdbc797617b6f842f3d5be16be6fb09321d7883cb5469333fa3434f725d7592e2a72b1bfc532876de803e3d0744b1
6
+ metadata.gz: 87f2e924550b4c3568e195e065b8e152091d452c177f5409f27ae637019e6e0643a15fde769f124954f23547981c7ef864fb9944659bd849cc20e35ab3f56d79
7
+ data.tar.gz: cb5e7f5c663ab02bad5c3d1ade8e1090ab2db8e87056af6d33fdd10fc75fa7f37b6e738c05abe81f0582cd4cc5480a47d204398855335ef1c6733dbb92ab7056
@@ -262,6 +262,16 @@ module Autobuild
262
262
  # It defaults to the global ArchiveImporter.timeout
263
263
  attr_accessor :timeout
264
264
 
265
+ # Tests whether the archive's content is stored within a subdirectory or
266
+ # not
267
+ #
268
+ # If it has a subdirectory, its name is assumed to be the package's
269
+ # basename, or the value returned by {archive_dir} if the archive_dir
270
+ # option was given to {initialize}
271
+ def has_subdirectory?
272
+ !@options[:no_subdirectory]
273
+ end
274
+
265
275
  # Creates a new importer which downloads +url+ in +cachedir+ and unpacks it. The following options
266
276
  # are allowed:
267
277
  # [:cachedir] the cache directory. Defaults to "#{Autobuild.prefix}/cache"
@@ -671,25 +671,21 @@ module Autobuild
671
671
  update_alternates(package)
672
672
  end
673
673
 
674
- # Check whether we are already at the requested state
675
- pinned_state = (commit || tag)
676
- if pinned_state && has_commit?(package, pinned_state)
677
- pinned_state = rev_parse(package, pinned_state)
678
- current_head = rev_parse(package, 'HEAD')
679
- if options[:reset]
680
- if current_head == pinned_state
681
- return
682
- end
683
- elsif commit_present_in?(package, pinned_state, current_head)
684
- return
674
+ pinned_state =
675
+ if commit then commit
676
+ elsif tag then "refs/tags/#{tag}"
677
+ end
678
+
679
+ if pinned_state
680
+ if !has_commit?(package, pinned_state)
681
+ fetch_commit = current_remote_commit(package, options[:only_local])
685
682
  end
683
+ pinned_state = rev_parse(package, pinned_state)
686
684
  end
687
- fetch_commit = current_remote_commit(package, options[:only_local])
688
685
 
689
686
  target_commit =
690
- if commit then commit
691
- elsif tag then "refs/tags/#{tag}"
692
- else fetch_commit
687
+ if pinned_state then pinned_state
688
+ else fetch_commit ||= current_remote_commit(package, options[:only_local])
693
689
  end
694
690
 
695
691
  # If we are tracking a commit/tag, just check it out and return
@@ -699,21 +695,43 @@ module Autobuild
699
695
  return
700
696
  end
701
697
 
702
- if !on_target_branch?(package)
698
+ if !on_local_branch?(package)
703
699
  package.message "%%s: switching to branch %s" % [local_branch]
704
700
  run_git(package, 'checkout', local_branch)
705
701
  end
706
702
 
703
+ # Check whether we are already at the requested state
704
+ if pinned_state
705
+ current_head = rev_parse(package, 'HEAD')
706
+ if options[:reset]
707
+ if current_head == pinned_state
708
+ return
709
+ elsif merge_if_simple(package, pinned_state)
710
+ return
711
+ end
712
+ elsif commit_present_in?(package, pinned_state, current_head)
713
+ return
714
+ elsif merge_if_simple(package, pinned_state)
715
+ return
716
+ end
717
+ end
718
+
719
+ fetch_commit ||= current_remote_commit(package, options[:only_local])
707
720
  if options[:reset]
708
721
  commit_pinning(package, target_commit, fetch_commit)
709
722
  else
710
- status = merge_status(package, target_commit)
711
- if status.needs_update?
712
- if !merge? && status.status == Status::NEEDS_MERGE
713
- raise PackageException.new(package, 'import'), "the local branch '#{local_branch}' and the remote branch #{branch} of #{package.name} have diverged, and I therefore refuse to update automatically. Go into #{package.importdir} and either reset the local branch or merge the remote changes"
714
- end
715
- run_git(package, 'merge', target_commit)
723
+ merge_if_simple(package, target_commit)
724
+ end
725
+ end
726
+
727
+ def merge_if_simple(package, target_commit)
728
+ status = merge_status(package, target_commit)
729
+ if status.needs_update?
730
+ if !merge? && status.status == Status::NEEDS_MERGE
731
+ raise PackageException.new(package, 'import'), "the local branch '#{local_branch}' and the remote branch #{branch} of #{package.name} have diverged, and I therefore refuse to update automatically. Go into #{package.importdir} and either reset the local branch or merge the remote changes"
716
732
  end
733
+ run_git(package, 'merge', target_commit)
734
+ true
717
735
  end
718
736
  end
719
737
 
@@ -242,6 +242,8 @@ class Importer
242
242
  #
243
243
  # @raises ConfigException if package.importdir exists and is not a directory
244
244
  #
245
+ # @option options [Boolean] :checkout_only (false) if true, the importer
246
+ # will not update an already checked-out package.
245
247
  # @option options [Boolean] :only_local (false) if true, will only perform
246
248
  # actions that do not require network access. Importers that do not
247
249
  # support this mode will simply do nothing
@@ -1,5 +1,5 @@
1
1
  module Autobuild
2
- VERSION = "1.9.0.b2" unless defined? Autobuild::VERSION
2
+ VERSION = "1.9.0.b3" unless defined? Autobuild::VERSION
3
3
  end
4
4
 
5
5
 
@@ -317,6 +317,17 @@ describe Autobuild::Git do
317
317
  importer.import(pkg)
318
318
  end
319
319
  end
320
+ it "switches to the local branch regardless of the presence of the tag or commit" do
321
+ importer.import(pkg)
322
+ head = importer.rev_parse(pkg, 'HEAD')
323
+ importer.run_git(pkg, 'reset', '--hard', 'master~1')
324
+ importer.run_git(pkg, 'branch', 'local')
325
+ importer.local_branch = 'local'
326
+ importer.relocate(importer.repository, tag: 'third_commit')
327
+ importer.update(pkg)
328
+ assert_equal 'refs/heads/local', importer.current_branch(pkg)
329
+ assert_equal head, importer.rev_parse(pkg, 'refs/remotes/autobuild/master')
330
+ end
320
331
  end
321
332
  describe "with a specific commit given" do
322
333
  def assert_on_commit(id)
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.0.b2
4
+ version: 1.9.0.b3
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-03-11 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -178,4 +178,5 @@ rubygems_version: 2.2.2
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: Library to handle build systems and import mechanisms
181
- test_files: []
181
+ test_files:
182
+ - test/suite.rb