Skip to content

Commit 471f518

Browse files
authored
Refactoring (heroku#1608)
* Format kwargs on multiple lines * Don't rely on CWD, prefer injected path * Remove redundant chdir (this is done outside already) * Do not rely on CWD prefer the injected path * Do not rely on CWD prefer the injected path * Prefer kwarg * Remove legacy CI code
1 parent 019c973 commit 471f518

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

lib/language_pack/base.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ def initialize(app_path: , cache_path: , gemfile_lock: )
3131
@fetchers = {:buildpack => LanguagePack::Fetcher.new(VENDOR_URL) }
3232
@arch = get_arch
3333
@report = HerokuBuildReport::GLOBAL
34-
35-
Dir.chdir app_path
3634
end
3735

3836
def get_arch

lib/language_pack/ruby.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def compile
7878
remove_vendor_bundle
7979
warn_bundler_upgrade
8080
warn_bad_binstubs
81-
install_ruby(slug_vendor_ruby)
81+
install_ruby(install_path: slug_vendor_ruby)
8282
setup_language_pack_environment(
8383
ruby_layer_path: File.expand_path("."),
8484
gem_layer_path: File.expand_path("."),
@@ -127,7 +127,10 @@ def config_detect
127127
# Since `ruby2.5` is not a valid binary name
128128
#
129129
def warn_bad_binstubs
130-
check = LanguagePack::Helpers::BinstubCheck.new(app_root_dir: Dir.pwd, warn_object: self)
130+
check = LanguagePack::Helpers::BinstubCheck.new(
131+
warn_object: self,
132+
app_root_dir: self.app_path,
133+
)
131134
check.call
132135
end
133136

@@ -467,7 +470,7 @@ def warn_outdated_minor
467470

468471
# install the vendored ruby
469472
# @return [Boolean] true if it installs the vendored ruby and false otherwise
470-
def install_ruby(install_path)
473+
def install_ruby(install_path: )
471474
# Could do a compare operation to avoid re-downloading ruby
472475
return false unless ruby_version
473476

@@ -552,7 +555,7 @@ def install_ruby(install_path)
552555
end
553556

554557
def new_app?
555-
@new_app ||= !File.exist?("vendor/heroku")
558+
@new_app ||= !app_path.join("vendor").join("heroku").exist?
556559
end
557560

558561
# find the ruby install path for its binstubs during build
@@ -631,14 +634,15 @@ def uninstall_binary(path)
631634
# users should be using `bundle pack` instead.
632635
# https://github.com/heroku/heroku-buildpack-ruby/issues/21
633636
def remove_vendor_bundle
634-
if File.exist?("vendor/bundle")
637+
vendor_bundle = self.app_path.join("vendor").join("bundle")
638+
if vendor_bundle.exist?
635639
warn(<<~WARNING)
636640
Removing `vendor/bundle`.
637641
Checking in `vendor/bundle` is not supported. Please remove this directory
638642
and add it to your .gitignore. To vendor your gems with Bundler, use
639643
`bundle pack` instead.
640644
WARNING
641-
FileUtils.rm_rf("vendor/bundle")
645+
vendor_bundle.rmtree
642646
end
643647
end
644648

lib/language_pack/test/ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def compile
88
new_app?
99
remove_vendor_bundle
1010
warn_bad_binstubs
11-
install_ruby(slug_vendor_ruby)
11+
install_ruby(install_path: slug_vendor_ruby)
1212
setup_language_pack_environment(
1313
ruby_layer_path: File.expand_path("."),
1414
gem_layer_path: File.expand_path("."),

spec/spec_helper.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ def create_file_with_size_in(size, dir)
4444
Pathname.new name
4545
end
4646

47-
if ENV['TRAVIS']
48-
# Don't execute tests against "merge" commits
49-
exit 0 if ENV['TRAVIS_PULL_REQUEST'] != 'false' && ENV['TRAVIS_BRANCH'] == 'master'
50-
end
51-
5247
def buildpack_path
5348
File.expand_path(File.join("../.."), __FILE__)
5449
end

0 commit comments

Comments
 (0)