Class: GitCommands::Push
- Defined in:
- lib/straight_line/common/git_commands/push.rb
Overview
Push a branch to remote
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
-
#initialize(branch, remote_exists = true, opts = {}) ⇒ Push
constructor
A new instance of Push.
- #push_command(branch, remote_exists, opts) ⇒ Object
Methods inherited from Command
#arg, from_file, #run, #run_sub_commands, #sub_command
Constructor Details
#initialize(branch, remote_exists = true, opts = {}) ⇒ Push
Returns a new instance of Push.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/straight_line/common/git_commands/push.rb', line 6 def initialize(branch, remote_exists = true, opts = {}) super('git') arg 'checkout' arg branch if remote_exists.is_a? Hash opts = remote_exists remote_exists = true end sub_command push_command(branch, remote_exists, opts) end |
Instance Method Details
#push_command(branch, remote_exists, opts) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/straight_line/common/git_commands/push.rb', line 18 def push_command(branch, remote_exists, opts) push_command = Command.new('git') .arg('push') if opts[:delete] push_command .arg('origin') .arg('--delete') .arg(branch) elsif !remote_exists push_command .arg('--set-upstream') .arg('origin') .arg(branch) end push_command end |