Class: Heroku::Command::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/heroku/command/git.rb

Overview

manage git for apps

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#api, #app, #heroku, #initialize, namespace

Methods included from Helpers

#action, #ask, #confirm, #confirm_billing, #confirm_command, #create_git_remote, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #home_directory, #host_name, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #with_tty

Constructor Details

This class inherits a constructor from Heroku::Command::Base

Instance Method Details

#cloneObject

git:clone APP [DIRECTORY]

clones a heroku app to your local machine at DIRECTORY (defaults to app name)

-r, –remote REMOTE # the git remote to create, default “heroku”

Examples:

$ pogo git:clone example Cloning from app ‘example’… Cloning into ‘example’… remote: Counting objects: 42, done. …



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/heroku/command/git.rb', line 21

def clone
  remote = options[:remote] || "heroku"

  name = options[:app] || shift_argument || error("Usage: pogo git:clone APP [DIRECTORY]")
  directory = shift_argument
  validate_arguments!

  git_url = api.get_app(name).body["git_url"]

  puts "Cloning from app '#{name}'..."
  system "git clone -o #{remote} #{git_url} #{directory}".strip
end

#remoteObject

git:remote [OPTIONS]

adds a git remote to an app repo

if OPTIONS are specified they will be passed to git remote add

-r, –remote REMOTE # the git remote to create, default “heroku”

Examples:

$ pogo git:remote -a example Git remote heroku added

$ pogo git:remote -a example ! Git remote heroku already exists



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/heroku/command/git.rb', line 52

def remote
  git_options = args.join(" ")
  remote = options[:remote] || 'heroku'

  if git('remote').split("\n").include?(remote)
    error("Git remote #{remote} already exists")
  else
    app_data = api.get_app(app).body
    create_git_remote(remote, app_data['git_url'])
  end
end