Class: Git::Commands::SymbolicRef::Update Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/symbolic_ref/update.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-symbolic-ref/2.53.0

Creates or updates a symbolic ref via git symbolic-ref

Given two arguments, creates or updates a symbolic ref <name> to point at the given branch <ref>.

Examples:

Update HEAD to point to a branch

cmd = Git::Commands::SymbolicRef::Update.new(execution_context)
cmd.call('HEAD', 'refs/heads/main')

Update HEAD with a reflog message

cmd = Git::Commands::SymbolicRef::Update.new(execution_context)
cmd.call('HEAD', 'refs/heads/main', m: 'switching to main')

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, ref, **options) ⇒ Git::CommandLineResult

Execute the git symbolic-ref command to create or update a symbolic ref

Parameters:

  • name (String)

    the symbolic ref name to update (e.g. HEAD)

  • ref (String)

    the target ref to point to (e.g. refs/heads/main)

  • options (Hash)

    command options

Options Hash (**options):

  • :m (String) — default: nil

    a reflog message for the update

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (ArgumentError)

    if the name operand is missing

  • (ArgumentError)

    if the ref operand is missing

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/symbolic_ref/update.rb', line 45