Class: Git::Commands::NameRev Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/name_rev.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-name-rev/2.53.0

Implements the git name-rev command

Finds symbolic names suitable for human digestion for revisions given in any format parsable by git rev-parse.

Examples:

Find the symbolic name for a commit

name_rev = Git::Commands::NameRev.new(execution_context)
result = name_rev.call('abc123')

Use only tags for naming

name_rev = Git::Commands::NameRev.new(execution_context)
result = name_rev.call('abc123', tags: true)

List all commits reachable from all refs

name_rev = Git::Commands::NameRev.new(execution_context)
result = name_rev.call(all: true)

Filter refs by pattern

name_rev = Git::Commands::NameRev.new(execution_context)
result = name_rev.call('abc123', refs: ['heads/*', 'tags/*'])

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

Execute the git name-rev command

Parameters:

  • commit_ish (Array<String>)

    zero or more commit-ish objects to find symbolic names for

  • options (Hash)

    command options

Options Hash (**options):

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

    use only tags to name the commits, not branch names

  • :refs (String, Array<String>) — default: nil

    only use refs whose names match the given shell pattern

    When given multiple times, uses refs whose names match any of the given shell patterns. Maps to --refs=<pattern>.

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

    clear all previously given --refs patterns

  • :exclude (String, Array<String>) — default: nil

    do not use any ref whose name matches the given shell pattern

    When given multiple times, a ref is excluded when it matches any of the given patterns. Maps to --exclude=<pattern>.

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

    clear all previously given --exclude patterns

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

    list all commits reachable from all refs

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

    transform stdin by substituting all 40-character SHA-1 hexes with their symbolic names. Maps to --annotate-stdin.

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

    print only the symbolic name, not the SHA-1

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

    die with non-zero exit code when a reference is undefined, instead of printing undefined

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

    show uniquely abbreviated commit object as fallback

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero status



# File 'lib/git/commands/name_rev.rb', line 57