Class: Git::Commands::ShowRef::Verify Private

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

Strict per-ref verification command via git show-ref --verify

Verifies that refs exist by their full canonical name (e.g. refs/heads/main, refs/tags/v1.0). Unlike List, partial name matching is not performed. Every named ref must start with refs/ (or be HEAD); anything else will cause git to exit non-zero.

When a ref cannot be resolved, git exits 1 and this class raises FailedError. This strict behaviour makes the class suitable for validating that refs are fully qualified.

For pattern-based listing, use List. For stdin-based filtering, use ExcludeExisting. For a silent boolean check (git >= 2.43), use Exists.

Examples:

Verify a single ref

cmd = Git::Commands::ShowRef::Verify.new(execution_context)
result = cmd.call('refs/heads/main')
result.stdout  # => "abc1234 refs/heads/main\n"

Verify with hash-only output

cmd = Git::Commands::ShowRef::Verify.new(execution_context)
result = cmd.call('refs/heads/main', hash: true)
result.stdout  # => "abc1234\n"

Silent existence check

cmd = Git::Commands::ShowRef::Verify.new(execution_context)
cmd.call('refs/heads/main', quiet: true)  # raises FailedError if not found

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

Execute git show-ref --verify to verify refs by their full name

Parameters:

  • ref (Array<String>)

    one or more fully-qualified ref names

    Each name must begin with refs/ (or be HEAD). At least one is required.

  • options (Hash)

    command options

Options Hash (**options):

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

    suppress all output

    Useful when you only care whether the ref exists.

    Alias: :q

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

    dereference annotated tags, emitting an extra ^{} line per tag

    Alias: :d

  • :hash (Boolean, Integer, nil) — default: nil

    show only the SHA part

    Pass true for full-length SHAs or an integer for abbreviation length.

    Alias: :s

  • :abbrev (Boolean, Integer, nil) — default: nil

    abbreviate object names

    Pass true for the default length or an integer for a specific length.

  • :timeout (Numeric) — default: nil

    abort the command after this many seconds

Returns:

Raises:

  • (ArgumentError)

    if no ref names are provided

  • (Git::FailedError)

    if any ref cannot be resolved (exit status 1)



# File 'lib/git/commands/show_ref/verify.rb', line 75