Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support local directories for fixtures #53

Merged
merged 3 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/hatchet/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def update_stack(stack_name)
def setup!
return self if @app_is_setup
puts "Hatchet setup: #{name.inspect} for #{repo_name.inspect}"
create_git_repo! unless is_git_repo?
create_app
set_labs!
buildpack_list = @buildpacks.map { |pack| { buildpack: pack } }
Expand All @@ -179,7 +180,6 @@ def before_deploy(&block)
self
end


def commit!
local_cmd_exec!('git add .; git commit -m next')
end
Expand Down Expand Up @@ -327,12 +327,21 @@ def api_rate_limit
true
end

private def is_git_repo?
out = `git rev-parse --git-dir > /dev/null 2>&1`
$?.success?
end

private def local_cmd_exec!(cmd)
out = `#{cmd}`
raise "Command: #{cmd} failed: #{out}" unless $?.success?
out
end

private def create_git_repo!
local_cmd_exec!('git init; git add .; git commit -m "init"')
end

private def default_name
"hatchet-t-#{SecureRandom.hex(10)}"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source 'https://rubygems.org'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
GEM
remote: https://rubygems.org/
specs:

PLATFORMS
ruby

DEPENDENCIES

BUNDLED WITH
1.16.2
14 changes: 14 additions & 0 deletions test/hatchet/local_repo_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'test_helper'

class AppTest < Minitest::Test
def test_repos_checked_into_git
app = Hatchet::App.new("test/different-folder-for-checked-in-repos/default_ruby")
app.in_directory do
assert_equal false, Dir.exist?(".git")
app.setup!
assert_equal true, Dir.exist?(".git")
end
ensure
app.teardown! if app
end
end