lib/git-process/git_lib.rb
#
# Pushes the given branch to the server.
#
# @param [String] remote_name the repository name; nil -> 'origin'
# @param [String] local_branch the local branch to push; nil -> the current branch
# @param [String] remote_branch the name of the branch to push to; nil -> same as local_branch
#
# @option opts [Boolean, String] :delete delete the remote branch
# @option opts [Boolean] :force force the update, even if not a fast-forward
#
# @return [void]
#
# @raise [ArgumentError] if :delete is true, but no branch name is given
Pushes the given branch to the server.
Pushes the given branch to the server .
def push(remote_name, local_branch, remote_branch, opts = {})
      remote_name ||= 'origin'
      args = [remote_name]
      if opts[:delete]
        if remote_branch
          rb = remote_branch
        elsif local_branch
          rb = local_branch
        elsif !(opts[:delete].is_a? TrueClass)
          rb = opts[:delete]
        else
          raise ArgumentError.new('Need a branch name to delete.')
        end
        int_branch = config.master_branch
        if rb == int_branch
          raise GitProc::GitProcessError.new("Can not delete the integration branch '#{int_branch}'")
        end
        logger.info { "Deleting remote branch '#{rb}' on '#{remote_name}'." }
        args << '--delete' << rb
      else
        local_branch ||= branches.current
        remote_branch ||= local_branch
        args << '-f' if opts[:force]
        logger.info do
          if local_branch == remote_branch
            "Pushing to '#{remote_branch}' on '#{remote_name}'."
          else
            "Pushing #{local_branch} to '#{remote_branch}' on '#{remote_name}'."
          end
        end
        args << "#{local_branch}:#{remote_branch}"
      end
      command(:push, args)
    end
def push ( remote_name , local_branch , remote_branch , opts = { } ) remote_name ||= 'origin' args = [ remote_name ] if opts [ :delete ] if remote_branch rb = remote_branch elsif local_branch rb = local_branch elsif ! ( opts [ :delete ] . is_a? TrueClass ) rb = opts [ :delete ] else raise ArgumentError . new ( 'Need a branch name to delete.' ) end int_branch = config . master_branch if rb == int_branch raise GitProc :: GitProcessError . new ( "Can not delete the integration branch '#{int_branch}'" ) end logger . info { "Deleting remote branch '#{rb}' on '#{remote_name}'." } args << '--delete' << rb else local_branch ||= branches . current remote_branch ||= local_branch args << '-f' if opts [ :force ] logger . info do if local_branch == remote_branch "Pushing to '#{remote_branch}' on '#{remote_name}'." else "Pushing #{local_branch} to '#{remote_branch}' on '#{remote_name}'." end end args << "#{local_branch}:#{remote_branch}" end command ( :push , args ) end
Pushes the given branch to the server.
Pushes the given branch to the server .
None
void
[ArgumentError] if :delete is true, but no branch name is given
[ ArgumentError ] if : delete is true but no branch name is given
remote_name
<not_specific>
local_branch
<not_specific>
remote_branch
<not_specific>
opts
:force force the update, even if not a fast-forward
: force force the update even if not a fast - forward
<not_specific>
remote_branch the name of the branch to push to; nil -> same as local_branch
remote_branch the name of the branch to push to ; nil - > same as local_branch