Skip to content
Browse files

trying another way to clear bundler env

  • Loading branch information...
1 parent 5fb843f commit e8a78ca87d9e81c0b67d0631f41857bd8a93652c Gabe Varela committed Apr 16, 2010
Showing with 43 additions and 32 deletions.
  1. +2 −1 init.rb
  2. +19 −8 lib/integrity/builder.rb
  3. +19 −22 lib/integrity/helpers/push.rb
  4. +1 −1 test/fixtures.rb
  5. +2 −0 test/helper.rb
View
3 init.rb
@@ -1,5 +1,6 @@
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
+ORIGINAL_ENV = ENV.to_hash
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
require ".bundle/environment"
require "integrity"
View
27 lib/integrity/builder.rb
@@ -48,16 +48,18 @@ def complete
def run
# HACK: gem bundler sets the RUBYOPT env variable which jacks with projects own gem management so unset in command
- cmd = "(cd #{repo.directory} && env - bash --login -c '#{@build.project.command}' 2>&1)"
+ cmd = "(#{@build.project.command} 2>&1)"
Integrity.logger.debug(cmd)
@output = ''
- IO.popen(cmd, "r") do |io|
- # incremental update of status
- io.each do |line|
- @output += line
- @build.update!(
- :output => @output
- )
+ with_clean_env do
+ IO.popen(cmd, "r") do |io|
+ # incremental update of status
+ io.each do |line|
+ @output += line
+ @build.update!(
+ :output => @output
+ )
+ end
end
end
@status = $?.success?
@@ -73,6 +75,15 @@ def commit
@build.commit.identifier
end
+ private
+
+ def with_clean_env
+ bundled_env = ENV.to_hash
+ ENV.replace(ORIGINAL_ENV)
+ yield
+ ensure
+ ENV.replace(bundled_env.to_hash)
+ end
end
end
View
41 lib/integrity/helpers/push.rb
@@ -2,20 +2,17 @@ module Integrity
module Helpers
def endpoint_token
%w[push github].include?(params[:endpoint]) &&
- settings.respond_to?(params[:endpoint]) &&
- settings.send(params[:endpoint])
+ settings.respond_to?(params[:endpoint]) &&
+ settings.send(params[:endpoint])
end
-
alias_method :endpoint_enabled?, :endpoint_token
def endpoint_payload
case params[:endpoint]
- when "push" then
- push_payload
- when "github" then
- github_payload
- else
- nil
+ when "push" then push_payload
+ when "github" then github_payload
+ else
+ nil
end
rescue JSON::JSONError
nil
@@ -34,26 +31,26 @@ def github_payload
branch = payload.delete("ref").split("/").last
uri =
- if repository["private"]
- "git@github.com:#{URI(repository["url"]).path[1..-1]}"
- else
- URI(repository["url"]).tap { |u| u.scheme = "git" }.to_s
- end
+ if repository["private"]
+ "git@github.com:#{URI(repository["url"]).path[1..-1]}"
+ else
+ URI(repository["url"]).tap { |u| u.scheme = "git" }.to_s
+ end
# TODO
uri = repository["url"] if settings.test?
commits =
- if settings.build_all?
- payload.delete("commits")
- else
- [payload["commits"].detect { |c| c["id"] == payload["after"] }]
- end
+ if settings.build_all?
+ payload.delete("commits")
+ else
+ [payload["commits"].detect { |c| c["id"] == payload["after"] }]
+ end
payload.update(
- "uri" => uri,
- "branch" => branch,
- "commits" => commits
+ "uri" => uri,
+ "branch" => branch,
+ "commits" => commits
)
end
end
View
2 test/fixtures.rb
@@ -21,7 +21,7 @@ module Integrity
{ :name => "Integrity",
:uri => "git://github.com/foca/integrity.git",
:branch => "master",
- :command => "bundle exec rake",
+ :command => "rake",
:public => true }
end
View
2 test/helper.rb
@@ -1,3 +1,5 @@
+ORIGINAL_ENV = ENV.to_hash
+
require "test/unit"
require "rr"
require "extlib"

0 comments on commit e8a78ca

Please sign in to comment.
Something went wrong with that request. Please try again.