Sha256: cbda4acc8331ec7f2c949d29559a834d163a35f1c4e093cf656f0512ffb360c2

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

require 'common/command'

module GitCommands
  # Push a branch to remote
  class Push < Command
    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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
straight_line-0.1.0.0 lib/common/git_commands/push.rb