diff --git a/plugins/pushes/heroku/push.rb b/plugins/pushes/heroku/push.rb index 360db9af0..b894eba81 100644 --- a/plugins/pushes/heroku/push.rb +++ b/plugins/pushes/heroku/push.rb @@ -19,9 +19,12 @@ module VagrantPlugins # Get the current branch branch = git_branch(dir) + # Get the name of the app + app = config.app || interpret_app(dir) + # Check if we need to add the git remote if !has_git_remote?(config.remote, dir) - add_heroku_git_remote(config.remote, config.app, dir) + add_heroku_git_remote(config.remote, app, dir) end # Push to Heroku @@ -45,6 +48,13 @@ module VagrantPlugins end end + # Interpret the name of the Heroku application from the given path. + # @param [String] path + # @return [String] + def interpret_app(path) + File.basename(path) + end + # The git directory for the given path. # @param [String] path # @return [String] diff --git a/test/unit/plugins/pushes/heroku/push_test.rb b/test/unit/plugins/pushes/heroku/push_test.rb index ab5a64eee..c0337e41f 100644 --- a/test/unit/plugins/pushes/heroku/push_test.rb +++ b/test/unit/plugins/pushes/heroku/push_test.rb @@ -222,6 +222,12 @@ describe VagrantPlugins::HerokuPush::Push do end end + describe "#interpret_app" do + it "returns the basename of the directory" do + expect(subject.interpret_app("/foo/bar/blitz")).to eq("blitz") + end + end + describe "#heroku_git_url" do it "returns the proper string" do expect(subject.heroku_git_url("bacon"))