autobuild 1.10.0.b2 → 1.10.0.b3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/autobuild/config.rb +5 -2
- data/lib/autobuild/import/git.rb +114 -6
- data/lib/autobuild/importer.rb +9 -0
- data/lib/autobuild/reporting.rb +2 -1
- data/lib/autobuild/subcommand.rb +5 -6
- data/lib/autobuild/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28218a1fe204bc6efd9ae8a5ca2635067dd1aa8f
|
4
|
+
data.tar.gz: dc5ea70ceb40b5798c5cbcfdbc53000dc1b0507d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a43bb95fbd578877a7559ea37323bdfaedc0a3197bf47a3b283667eb99b3c83d8079bdd4a2627c03ade5802a475e140c93bdf5aadcc075d8f42cb0fec3689c1d
|
7
|
+
data.tar.gz: b18e69dfe1aa5373a538d277ba30f455c94555b6de1c8a2335216545f0b37d8761920d1bd454bc9148f8ffed335aaf23e7e4225215ca2073fbbf2a24d770587c
|
data/lib/autobuild/config.rb
CHANGED
@@ -275,7 +275,10 @@ module Autobuild
|
|
275
275
|
utilities.keys
|
276
276
|
end
|
277
277
|
|
278
|
-
def self.apply(packages, buildname = "autobuild", phases = [])
|
278
|
+
def self.apply(packages, buildname = "autobuild", phases = [], options = Hash.new)
|
279
|
+
options = Kernel.validate_options options,
|
280
|
+
parallel: Autobuild.parallel_build_level
|
281
|
+
|
279
282
|
if Autobuild.mail[:to]
|
280
283
|
if !Autobuild::HAS_RMAIL
|
281
284
|
Autobuild.warn "RMail is not available. Mail notification is disabled"
|
@@ -322,7 +325,7 @@ module Autobuild
|
|
322
325
|
end
|
323
326
|
|
324
327
|
begin
|
325
|
-
invoker = Autobuild::RakeTaskParallelism.new
|
328
|
+
invoker = Autobuild::RakeTaskParallelism.new(options[:parallel])
|
326
329
|
Autobuild.parallel_task_manager = invoker
|
327
330
|
phases.each do |phase|
|
328
331
|
invoker.invoke_parallel([Rake::Task["#{buildname}-#{phase}"]])
|
data/lib/autobuild/import/git.rb
CHANGED
@@ -364,11 +364,37 @@ module Autobuild
|
|
364
364
|
end
|
365
365
|
end
|
366
366
|
|
367
|
+
# Resolve a commit ref to a tag or commit ID
|
368
|
+
def describe_rev(package, rev)
|
369
|
+
tag = run_git_bare(package, 'describe', '--tags', '--exact-match', rev).first.strip
|
370
|
+
return true, tag.encode('UTF-8')
|
371
|
+
rescue Autobuild::SubcommandFailed
|
372
|
+
commit = rev_parse(package, rev)
|
373
|
+
return false, commit.encode('UTF-8')
|
374
|
+
end
|
375
|
+
|
376
|
+
# Enumerates the ref that are present on the remote
|
377
|
+
#
|
378
|
+
# @yieldparam [String] ref_name the ref name
|
379
|
+
# @yieldparam [String] commit_id the ref's commit ID
|
380
|
+
def each_remote_ref(package)
|
381
|
+
return enum_for(__method__, package) if !block_given?
|
382
|
+
run_git_bare(package, 'ls-remote', repository).each do |line|
|
383
|
+
commit_id, ref_name = line.split(/\s+/)
|
384
|
+
if ref_name !~ /\^/
|
385
|
+
yield(ref_name, commit_id)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
367
390
|
# Fetches updates from the remote repository. Returns the remote commit
|
368
391
|
# ID on success, nil on failure. Expects the current directory to be the
|
369
392
|
# package's source directory.
|
370
|
-
def fetch_remote(package)
|
393
|
+
def fetch_remote(package, options = Hash.new)
|
371
394
|
validate_importdir(package)
|
395
|
+
options = Kernel.validate_options options,
|
396
|
+
refspec: remote_branch || tag
|
397
|
+
|
372
398
|
git_dir = git_dir(package, false)
|
373
399
|
|
374
400
|
# If we are checking out a specific commit, we don't know which
|
@@ -381,7 +407,7 @@ module Autobuild
|
|
381
407
|
# Doing it now is better as it makes sure that we replace the
|
382
408
|
# configuration parameters only if the repository and branch are
|
383
409
|
# OK (i.e. we keep old working configuration instead)
|
384
|
-
refspec = [
|
410
|
+
refspec = Array(options[:refspec])
|
385
411
|
run_git_bare(package, 'fetch', '--tags', repository, *refspec, retry: true)
|
386
412
|
|
387
413
|
update_remotes_configuration(package)
|
@@ -397,7 +423,7 @@ module Autobuild
|
|
397
423
|
end
|
398
424
|
|
399
425
|
# Update the remote tag if needs be
|
400
|
-
if
|
426
|
+
if remote_branch && commit_id
|
401
427
|
run_git_bare(package, 'update-ref', "-m", "updated by autobuild", "refs/remotes/#{remote_name}/#{remote_branch}", commit_id)
|
402
428
|
end
|
403
429
|
|
@@ -445,6 +471,13 @@ module Autobuild
|
|
445
471
|
remote_commit = current_remote_commit(package, only_local)
|
446
472
|
status = merge_status(package, remote_commit)
|
447
473
|
status.uncommitted_code = self.class.has_uncommitted_changes?(package)
|
474
|
+
if current_branch = self.current_branch(package)
|
475
|
+
if current_branch != "refs/heads/#{local_branch}"
|
476
|
+
status.unexpected_working_copy_state << "working copy is on branch #{current_branch}, the autoproj configuration expected it to be on #{local_branch}"
|
477
|
+
end
|
478
|
+
else
|
479
|
+
status.unexpected_working_copy_state << "working copy is on a detached HEAD"
|
480
|
+
end
|
448
481
|
status
|
449
482
|
end
|
450
483
|
|
@@ -553,7 +586,7 @@ module Autobuild
|
|
553
586
|
# Tests whether a commit is already present in a given history
|
554
587
|
#
|
555
588
|
# @param [Package] the package we are working on
|
556
|
-
# @param [String]
|
589
|
+
# @param [String] rev what we want to verify the presence of
|
557
590
|
# @param [String] reference the reference commit. The method tests that
|
558
591
|
# 'commit' is present in the history of 'reference'
|
559
592
|
#
|
@@ -569,6 +602,71 @@ module Autobuild
|
|
569
602
|
end
|
570
603
|
end
|
571
604
|
|
605
|
+
# Finds a remote reference that contains a commit
|
606
|
+
#
|
607
|
+
# It will favor the configured {#remote_branch} if it matches
|
608
|
+
#
|
609
|
+
# @param [Autobuild::Package] package the package we are working on
|
610
|
+
# @param [String] commit_id the commit ID (can be a rev)
|
611
|
+
# @return [String] a remote ref
|
612
|
+
# @raise [PackageException] if there is no such commit on the remote
|
613
|
+
def describe_commit_on_remote(package, rev = 'HEAD', options = Hash.new)
|
614
|
+
rev = rev.to_str
|
615
|
+
options = Kernel.validate_options options,
|
616
|
+
tags: true
|
617
|
+
|
618
|
+
commit_id = rev_parse(package, rev)
|
619
|
+
|
620
|
+
remote_refs = Hash[*each_remote_ref(package).to_a.flatten]
|
621
|
+
remote_branch_ref = "refs/heads/#{remote_branch}"
|
622
|
+
remote_branch_id = remote_refs.delete(remote_branch_ref)
|
623
|
+
begin
|
624
|
+
if commit_present_in?(package, commit_id, remote_branch_id)
|
625
|
+
return remote_branch
|
626
|
+
end
|
627
|
+
rescue PackageException # We have to fetch. Fetch all branches at once
|
628
|
+
fetch_remote(package, refspec: [remote_branch_ref, *remote_refs.keys])
|
629
|
+
if commit_present_in?(package, commit_id, remote_branch_id)
|
630
|
+
return remote_branch
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
634
|
+
if !options[:tags]
|
635
|
+
remote_refs.delete_if { |r| r =~ /^refs\/tags\// }
|
636
|
+
end
|
637
|
+
|
638
|
+
# Prefer tags, then heads, then the rest (e.g. github pull requests)
|
639
|
+
remote_refs = remote_refs.sort_by do |rev_name, rev_id|
|
640
|
+
case rev_name
|
641
|
+
when /^refs\/tags\// then 0
|
642
|
+
when /^refs\/heads\// then 1
|
643
|
+
else 2
|
644
|
+
end
|
645
|
+
end
|
646
|
+
|
647
|
+
remote_refs.delete_if do |rev_name, rev_id|
|
648
|
+
begin
|
649
|
+
if commit_present_in?(package, commit_id, rev_id)
|
650
|
+
return rev_name
|
651
|
+
end
|
652
|
+
true
|
653
|
+
rescue PackageException
|
654
|
+
false
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
if !remote_refs.empty?
|
659
|
+
fetch_remote(package, refspec: remote_refs.map(&:first))
|
660
|
+
remote_refs.each do |rev_name, rev_id|
|
661
|
+
if commit_present_in?(package, commit_id, rev_id)
|
662
|
+
return rev_name
|
663
|
+
end
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
667
|
+
raise PackageException.new(package), "current HEAD (#{commit_id}) does not seem to be present on the remote"
|
668
|
+
end
|
669
|
+
|
572
670
|
# Computes the update status to update a branch whose tip is at
|
573
671
|
# reference_commit (which can be a symbolic reference) using the
|
574
672
|
# fetch_commit commit
|
@@ -798,8 +896,18 @@ module Autobuild
|
|
798
896
|
|
799
897
|
# Changes the repository this importer is pointing to
|
800
898
|
def relocate(repository, options = Hash.new)
|
899
|
+
options = Hash[options.map { |k, v| [k.to_sym, v] }]
|
900
|
+
|
801
901
|
@push_to = options[:push_to] || @push_to
|
802
|
-
@branch =
|
902
|
+
@branch = @local_branch = @remote_branch = nil
|
903
|
+
local_branch = options[:local_branch] || options[:branch] || local_branch || 'master'
|
904
|
+
remote_branch = options[:remote_branch] || options[:branch] || remote_branch || 'master'
|
905
|
+
if local_branch == remote_branch
|
906
|
+
@branch = local_branch
|
907
|
+
else
|
908
|
+
@local_branch = local_branch
|
909
|
+
@remote_branch = remote_branch
|
910
|
+
end
|
803
911
|
@tag = options[:tag] || @tag
|
804
912
|
@commit = options[:commit] || @commit
|
805
913
|
|
@@ -807,7 +915,7 @@ module Autobuild
|
|
807
915
|
@repository_id = options[:repository_id] ||
|
808
916
|
"git:#{@repository}"
|
809
917
|
@source_id = options[:source_id] ||
|
810
|
-
"#{@repository_id} branch=#{
|
918
|
+
"#{@repository_id} branch=#{remote_branch} tag=#{self.tag} commit=#{self.commit}"
|
811
919
|
end
|
812
920
|
|
813
921
|
# Tests whether the given directory is a git repository
|
data/lib/autobuild/importer.rb
CHANGED
@@ -45,6 +45,14 @@ class Importer
|
|
45
45
|
attr_accessor :status
|
46
46
|
# True if there is code in the working copy that is not committed
|
47
47
|
attr_accessor :uncommitted_code
|
48
|
+
# A list of messages describing differences between the local working
|
49
|
+
# copy and its expected state
|
50
|
+
#
|
51
|
+
# On git, it would for instance mention that currently checked out
|
52
|
+
# branch is not the one autoproj expects
|
53
|
+
#
|
54
|
+
# @return [Array<String>]
|
55
|
+
attr_reader :unexpected_working_copy_state
|
48
56
|
|
49
57
|
# An array of strings that represent commits that are in the remote
|
50
58
|
# repository and not in this one (would be merged by an update)
|
@@ -55,6 +63,7 @@ class Importer
|
|
55
63
|
|
56
64
|
def initialize(status = -1)
|
57
65
|
@status = status
|
66
|
+
@unexpected_working_copy_state = Array.new
|
58
67
|
@uncommitted_code = false
|
59
68
|
@remote_commits = Array.new
|
60
69
|
@local_commits = Array.new
|
data/lib/autobuild/reporting.rb
CHANGED
@@ -102,11 +102,12 @@ module Autobuild
|
|
102
102
|
|
103
103
|
if block_given?
|
104
104
|
begin
|
105
|
-
yield
|
105
|
+
result = yield
|
106
106
|
if options[:done_message] && has_progress_for?(key)
|
107
107
|
progress(key, *options[:done_message])
|
108
108
|
end
|
109
109
|
progress_done(key, true)
|
110
|
+
result
|
110
111
|
rescue Exception
|
111
112
|
progress_done(key, false)
|
112
113
|
raise
|
data/lib/autobuild/subcommand.rb
CHANGED
@@ -197,14 +197,15 @@ module Autobuild::Subprocess
|
|
197
197
|
STDOUT.sync = true
|
198
198
|
|
199
199
|
input_streams = []
|
200
|
-
options = Hash[retry: false, env: ENV.to_hash, env_inherit: true]
|
200
|
+
options = Hash[retry: false, env: ENV.to_hash, env_inherit: true, encoding: 'BINARY']
|
201
201
|
if command.last.kind_of?(Hash)
|
202
202
|
options = command.pop
|
203
203
|
options = Kernel.validate_options options,
|
204
204
|
input: nil, working_directory: nil, retry: false,
|
205
205
|
input_streams: [],
|
206
206
|
env: ENV.to_hash,
|
207
|
-
env_inherit: true
|
207
|
+
env_inherit: true,
|
208
|
+
encoding: 'BINARY'
|
208
209
|
|
209
210
|
if options[:input]
|
210
211
|
input_streams << File.open(options[:input])
|
@@ -246,9 +247,7 @@ module Autobuild::Subprocess
|
|
246
247
|
elsif Autobuild.registered_logfile?(logname) then 'a'
|
247
248
|
else 'w'
|
248
249
|
end
|
249
|
-
|
250
|
-
open_flag << ":BINARY"
|
251
|
-
end
|
250
|
+
open_flag << ":BINARY"
|
252
251
|
|
253
252
|
Autobuild.register_logfile(logname)
|
254
253
|
subcommand_output = Array.new
|
@@ -385,7 +384,7 @@ module Autobuild::Subprocess
|
|
385
384
|
# line-by-line.
|
386
385
|
outwrite.close
|
387
386
|
outread.each_line do |line|
|
388
|
-
line.force_encoding(
|
387
|
+
line.force_encoding(options[:encoding])
|
389
388
|
line = line.chomp
|
390
389
|
subcommand_output << line
|
391
390
|
|
data/lib/autobuild/version.rb
CHANGED
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.10.0.
|
4
|
+
version: 1.10.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-08-
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|