Skip to content

Instantly share code, notes, and snippets.

@quinn
Created April 22, 2014 21:35
Show Gist options
  • Save quinn/11195235 to your computer and use it in GitHub Desktop.
Save quinn/11195235 to your computer and use it in GitHub Desktop.
def extract_app_in_dir(dir)
return unless remotes = git_remotes(dir)
current_app = false
begin
current_app = File.read(FileUtils.pwd + '/.current-heroku-app').chomp
rescue Errno::ENOENT
end
if remote = options[:remote]
remotes[remote]
elsif remote = extract_app_from_git_config
remotes[remote]
else
apps = remotes.values.uniq
if apps.size == 1
apps.first
elsif current_app && apps.include?(current_app)
current_app
else
raise(Heroku::Command::CommandFailed, "Multiple apps in folder and no app specified.\nSpecify app with --app APP.") unless options[:ignore_no_app]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment