summaryrefslogtreecommitdiff
path: root/spec/support/builders.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/builders.rb')
-rw-r--r--spec/support/builders.rb76
1 files changed, 38 insertions, 38 deletions
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 021057cc3c..467a9f2ccd 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -394,7 +394,7 @@ module Spec
@_build_repo = File.basename(path)
yield
with_gem_path_as Path.base_system_gems do
- Dir.chdir(path) { gem_command! :generate_index }
+ gem_command! :generate_index, :dir => path
end
ensure
@_build_path = nil
@@ -551,6 +551,11 @@ module Spec
@files = {}
end
+ def capture(cmd, dir)
+ output, _status = Open3.capture2e(cmd, :chdir => dir)
+ output
+ end
+
def method_missing(*args, &blk)
@spec.send(*args, &blk)
end
@@ -660,14 +665,12 @@ module Spec
path = options[:path] || _default_path
source = options[:source] || "git@#{path}"
super(options.merge(:path => path, :source => source))
- Dir.chdir(path) do
- `git init`
- `git add *`
- `git config user.email "lol@wut.com"`
- `git config user.name "lolwut"`
- `git config commit.gpgsign false`
- `git commit -m "OMG INITIAL COMMIT"`
- end
+ capture("git init", path)
+ capture("git add *", path)
+ capture("git config user.email \"lol@wut.com\"", path)
+ capture("git config user.name \"lolwut\"", path)
+ capture("git config commit.gpgsign false", path)
+ capture("git commit -m \"OMG INITIAL COMMIT\"", path)
end
end
@@ -675,15 +678,14 @@ module Spec
def _build(options)
path = options[:path] || _default_path
super(options.merge(:path => path))
- Dir.chdir(path) do
- `git init --bare`
- end
+ capture("git init --bare", path)
end
end
class GitUpdater < LibBuilder
- def silently(str)
- `#{str} 2>#{Bundler::NULL}`
+ def silently(str, dir)
+ output, _error, _status = Open3.capture3(str, :chdir => dir)
+ output
end
def _build(options)
@@ -691,34 +693,32 @@ module Spec
update_gemspec = options[:gemspec] || false
source = options[:source] || "git@#{libpath}"
- Dir.chdir(libpath) do
- silently "git checkout master"
+ silently "git checkout master", libpath
- if branch = options[:branch]
- raise "You can't specify `master` as the branch" if branch == "master"
- escaped_branch = Shellwords.shellescape(branch)
+ if branch = options[:branch]
+ raise "You can't specify `master` as the branch" if branch == "master"
+ escaped_branch = Shellwords.shellescape(branch)
- if `git branch | grep #{escaped_branch}`.empty?
- silently("git branch #{escaped_branch}")
- end
-
- silently("git checkout #{escaped_branch}")
- elsif tag = options[:tag]
- `git tag #{Shellwords.shellescape(tag)}`
- elsif options[:remote]
- silently("git remote add origin #{options[:remote]}")
- elsif options[:push]
- silently("git push origin #{options[:push]}")
+ if capture("git branch | grep #{escaped_branch}", libpath).empty?
+ silently("git branch #{escaped_branch}", libpath)
end
- current_ref = `git rev-parse HEAD`.strip
- _default_files.keys.each do |path|
- _default_files[path] += "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'"
- end
- super(options.merge(:path => libpath, :gemspec => update_gemspec, :source => source))
- `git add *`
- `git commit -m "BUMP"`
+ silently("git checkout #{escaped_branch}", libpath)
+ elsif tag = options[:tag]
+ capture("git tag #{Shellwords.shellescape(tag)}", libpath)
+ elsif options[:remote]
+ silently("git remote add origin #{options[:remote]}", libpath)
+ elsif options[:push]
+ silently("git push origin #{options[:push]}", libpath)
+ end
+
+ current_ref = silently("git rev-parse HEAD", libpath).strip
+ _default_files.keys.each do |path|
+ _default_files[path] += "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'"
end
+ super(options.merge(:path => libpath, :gemspec => update_gemspec, :source => source))
+ capture("git add *", libpath)
+ capture("git commit -m \"BUMP\"", libpath)
end
end
@@ -739,7 +739,7 @@ module Spec
def git(cmd)
Bundler::SharedHelpers.with_clean_git_env do
- Dir.chdir(@path) { `git #{cmd}`.strip }
+ Open3.capture2e("git #{cmd}", :chdir => path)[0].strip
end
end
end