Class: Git::Commands::Remote::SetUrl Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/remote/set_url.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

arguments block audited against https://git-scm.com/docs/git-remote/2.53.0

git remote set-url command

Replaces a URL in the named remote's configuration. Sets the first URL for the remote matching regex (or the first URL if no is given) to .

Examples:

Replace the fetch URL for a remote

set_url = Git::Commands::Remote::SetUrl.new(execution_context)
set_url.call('origin', 'https://example.com/repo.git')

Replace the push URL for a remote

set_url = Git::Commands::Remote::SetUrl.new(execution_context)
set_url.call('origin', 'https://example.com/repo.git', push: true)

Replace a URL matching a regex

set_url = Git::Commands::Remote::SetUrl.new(execution_context)
set_url.call('origin', 'https://new.example.com/repo.git', 'old.example.com')

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(name, newurl, oldurl = nil, **options) ⇒ Git::CommandLineResult

Execute the git remote set-url command

Parameters:

  • name (String)

    the remote name to update

  • newurl (String)

    the replacement URL

  • oldurl (String, nil) (defaults to: nil)

    a regex matching the existing URL to replace

  • options (Hash)

    command options

Options Hash (**options):

  • :push (Boolean, nil) — default: nil

    update push URLs instead of fetch URLs

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/remote/set_url.rb', line 47