Skip to content

Commit b6488b5

Browse files
author
Kevin Paulisse
committed
Merge remote-tracking branch 'origin/kpaulisse-bootstrap-debug' into kpaulisse-octocatalog-diff-0-5-4
2 parents 8e14d69 + e0d9681 commit b6488b5

14 files changed

Lines changed: 276 additions & 1 deletion

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Option to bootstrap the current directory (by default, the bootstrap script is NOT
2+
# run when the catalog builds in the current directory).
3+
# @param parser [OptionParser object] The OptionParser argument
4+
# @param options [Hash] Options hash being constructed; this is modified in this method.
5+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:bootstrap_current) do
6+
has_weight 48
7+
8+
def parse(parser, options)
9+
parser.on('--bootstrap-current', 'Run bootstrap script for the current directory too') do
10+
options[:bootstrap_current] = true
11+
end
12+
end
13+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Option to print debugging output for the bootstrap script in addition to the normal
2+
# debugging output. Note that `--debug` must also be enabled for this option to have
3+
# any effect.
4+
# @param parser [OptionParser object] The OptionParser argument
5+
# @param options [Hash] Options hash being constructed; this is modified in this method.
6+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:debug_bootstrap) do
7+
has_weight 49
8+
9+
def parse(parser, options)
10+
parser.on('--debug-bootstrap', 'Print debugging output for bootstrap script') do
11+
options[:debug_bootstrap] = true
12+
end
13+
end
14+
end

lib/octocatalog-diff/catalog-util/bootstrap.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ def self.install_bootstrap_script(logger, opts)
136136
def self.run_bootstrap(logger, opts)
137137
logger.debug("Begin bootstrap with '#{opts[:bootstrap_script]}' in #{opts[:path]}")
138138
result = OctocatalogDiff::Bootstrap.bootstrap(opts)
139+
if opts[:debug_bootstrap] || result[:status_code] > 0
140+
output = result[:output].split(/[\r\n]+/)
141+
output.each { |x| logger.debug("Bootstrap: #{x}") }
142+
end
139143
raise BootstrapError, "bootstrap failed for #{opts[:path]}: #{result[:output]}" unless (result[:status_code]).zero?
140144
logger.debug("Success bootstrap in #{opts[:path]}")
141145
result[:output]

lib/octocatalog-diff/catalog/computed.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,17 @@ def bootstrap(logger)
9797
raise Errno::ENOENT, "Invalid dir #{@opts[:bootstrapped_dir]}" unless File.directory?(@opts[:bootstrapped_dir])
9898
tmphash[:basedir] = @opts[:bootstrapped_dir]
9999
elsif @opts[:branch] == '.'
100-
tmphash[:basedir] = @opts[:basedir]
100+
if @opts[:bootstrap_current]
101+
tmphash[:basedir] = Dir.mktmpdir
102+
at_exit { cleanup_checkout_dir(tmphash[:basedir], logger) }
103+
104+
FileUtils.cp_r File.join(@opts[:basedir], '.'), tmphash[:basedir]
105+
106+
o = @opts.reject { |k, _v| k == :branch }.merge(path: tmphash[:basedir])
107+
OctocatalogDiff::CatalogUtil::Bootstrap.bootstrap_directory(o, logger)
108+
else
109+
tmphash[:basedir] = @opts[:basedir]
110+
end
101111
else
102112
checkout_dir = Dir.mktmpdir
103113
at_exit { cleanup_checkout_dir(checkout_dir, logger) }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
ls -lR > /tmp/foo.$$
3+
echo "Hello, stdout"
4+
echo "Hello, stderr" 1>&2
5+
cp -r external-modules/test modules
6+
exit 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
echo "Fail, stdout"
4+
echo "Fail, stderr" 1>&2
5+
exit 1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class test {
2+
file { '/tmp/foo':
3+
content => template('test/foo.erb'),
4+
}
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test 123
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include test

spec/octocatalog-diff/fixtures/repos/bootstrap/modules/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)