From 711390205f06babf4b26b5e24345c1b5a65f8b78 Mon Sep 17 00:00:00 2001 From: Jean-Paul Bonnetouche Date: Wed, 19 Sep 2012 12:07:10 +0200 Subject: [PATCH 1/3] Fix use Bundler.with_clean_env Project using Bundler may conflicts with strano itself --- Capfile.repos | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Capfile.repos b/Capfile.repos index 1242ff6..c457a00 100644 --- a/Capfile.repos +++ b/Capfile.repos @@ -4,4 +4,21 @@ colorize [ { :match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore }, { :match => /^transaction: commit$/, :color => :magenta, :prio => 10, :attribute => :blink }, { :match => /git/, :color => :white, :prio => 20, :attribute => :reverse }, -] \ No newline at end of file +] + +# logs the command then executes it locally. +# returns the command output as a string +def run_locally(cmd) + logger.trace "executing locally: #{cmd.inspect}" if logger + output_on_stdout = nil + elapsed = Benchmark.realtime do + Bundler.with_clean_env do + output_on_stdout = `#{cmd}` + end + end + if $?.to_i > 0 # $? is command exit code (posix style) + raise Capistrano::LocalArgumentError, "Command #{cmd} returned status code #{$?}" + end + logger.trace "command finished in #{(elapsed * 1000).round}ms" if logger + output_on_stdout +end From bff99c230b4b635d0c5ec3b5948cc5fdf2ed1777 Mon Sep 17 00:00:00 2001 From: Jean-Paul Bonnetouche Date: Mon, 24 Sep 2012 21:02:52 +0200 Subject: [PATCH 2/3] Make it less error-prone --- Capfile.repos | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Capfile.repos b/Capfile.repos index c457a00..7a6d52b 100644 --- a/Capfile.repos +++ b/Capfile.repos @@ -6,19 +6,14 @@ colorize [ { :match => /git/, :color => :white, :prio => 20, :attribute => :reverse }, ] +# MonkeyPatch run_locally so that we use Bundler.with_clean_env +alias run_locally_without_bundler_clean_env run_locally +alias run_locally run_locally_with_bundler_clean_env + # logs the command then executes it locally. # returns the command output as a string -def run_locally(cmd) - logger.trace "executing locally: #{cmd.inspect}" if logger - output_on_stdout = nil - elapsed = Benchmark.realtime do - Bundler.with_clean_env do - output_on_stdout = `#{cmd}` - end - end - if $?.to_i > 0 # $? is command exit code (posix style) - raise Capistrano::LocalArgumentError, "Command #{cmd} returned status code #{$?}" +def run_locally_with_bundler_clean_env(cmd) + Bundler.with_clean_env do + run_locally_without_bundler_clean_env(cmd) end - logger.trace "command finished in #{(elapsed * 1000).round}ms" if logger - output_on_stdout end From de0829acddf731c906e9767a4d70e7ec6e75d7f9 Mon Sep 17 00:00:00 2001 From: Jean-Paul Bonnetouche Date: Wed, 26 Sep 2012 15:31:31 +0200 Subject: [PATCH 3/3] Fix override method when triggering the load event --- Capfile.repos | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Capfile.repos b/Capfile.repos index 7a6d52b..dce7f1f 100644 --- a/Capfile.repos +++ b/Capfile.repos @@ -6,14 +6,18 @@ colorize [ { :match => /git/, :color => :white, :prio => 20, :attribute => :reverse }, ] -# MonkeyPatch run_locally so that we use Bundler.with_clean_env -alias run_locally_without_bundler_clean_env run_locally -alias run_locally run_locally_with_bundler_clean_env +on :load do + # MonkeyPatch run_locally so that we use Bundler.with_clean_env + # logs the command then executes it locally. -# logs the command then executes it locally. -# returns the command output as a string -def run_locally_with_bundler_clean_env(cmd) - Bundler.with_clean_env do - run_locally_without_bundler_clean_env(cmd) + # returns the command output as a string + def run_locally_with_bundler_clean_env(cmd) + Bundler.with_clean_env do + run_locally_without_bundler_clean_env(cmd) + end end + + alias run_locally_without_bundler_clean_env run_locally + alias run_locally run_locally_with_bundler_clean_env + end