Class: GitPusshuTen::Commands::Push
- Defined in:
- lib/gitpusshuten/commands/push.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Base
#cli, #command, #configuration, #environment, #hooks, #perform_hooks
Instance Method Summary collapse
-
#initialize(*objects) ⇒ Push
constructor
A new instance of Push.
-
#perform_branch! ⇒ Object
Pushes the specified branch to the remote environment.
-
#perform_ref! ⇒ Object
Pushes the specified ref to the remote environment.
-
#perform_tag! ⇒ Object
Pushes the specified tag to the remote environment.
-
#set_remote! ⇒ Object
Adds the remote.
Methods inherited from Base
#c, #command_object, description, #e, #error, example, #g, #git, #help, #local, long_description, #message, #perform!, #perform_hooks!, #post_perform!, #pre_perform!, #prompt_for_root_password!, #prompt_for_user_password!, #r, #requires_user_existence!, #silent, #standard, usage, #validate!, #warning, #y, #yes?
Constructor Details
#initialize(*objects) ⇒ Push
Returns a new instance of Push.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gitpusshuten/commands/push.rb', line 14 def initialize(*objects) super perform_hooks! @command = cli.arguments.shift @type = cli.arguments.shift if %(production staging).include?(command) and not type c.environment = command @type = (command == 'production') ? 'master' : 'develop' @command = 'branch' end help unless type and e.name set_remote! end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
12 13 14 |
# File 'lib/gitpusshuten/commands/push.rb', line 12 def type @type end |
Instance Method Details
#perform_branch! ⇒ Object
Pushes the specified branch to the remote environment.
34 35 36 37 |
# File 'lib/gitpusshuten/commands/push.rb', line 34 def perform_branch! "Pushing branch #{y(type)} to the #{y(e.name)} environment." git.push(:branch, type).to(e.name) end |
#perform_ref! ⇒ Object
Pushes the specified ref to the remote environment.
48 49 50 51 |
# File 'lib/gitpusshuten/commands/push.rb', line 48 def perform_ref! "Pushing ref #{y(type)} to the #{y(e.name)} environment." git.push(:ref, type).to(e.name) end |
#perform_tag! ⇒ Object
Pushes the specified tag to the remote environment.
41 42 43 44 |
# File 'lib/gitpusshuten/commands/push.rb', line 41 def perform_tag! "Pushing tag #{y(type)} to the #{y(e.name)} environment." git.push(:tag, type).to(e.name) end |
#set_remote! ⇒ Object
Adds the remote
55 56 57 58 |
# File 'lib/gitpusshuten/commands/push.rb', line 55 def set_remote! git.remove_remote(e.name) if git.has_remote?(e.name) git.add_remote(e.name, "ssh://#{c.user}@#{c.ip}:#{c.port}/#{e.app_dir}") end |