Class: Git::Commands::Branch::List Private

Inherits:
Git::Commands::Base show all
Defined in:
lib/git/commands/branch/list.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-branch/2.53.0

Implements the git branch --list command

Examples:

Basic branch listing

list = Git::Commands::Branch::List.new(execution_context)
branches = list.call

List all branches (local and remote)

list = Git::Commands::Branch::List.new(execution_context)
all_branches = list.call(all: true)

List branches containing a commit

list = Git::Commands::Branch::List.new(execution_context)
branches = list.call(contains: 'abc123')

List branches with patterns

list = Git::Commands::Branch::List.new(execution_context)
feature_branches = list.call('feature/*')

See Also:

Instance Method Summary collapse

Methods inherited from Git::Commands::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(*pattern, **options) ⇒ Git::CommandLineResult

Execute the git branch --list command

Parameters:

  • pattern (Array<String>)

    shell wildcard patterns to filter branches

    If multiple patterns are given, a branch is shown if it matches any of the patterns.

  • options (Hash)

    command options

Options Hash (**options):

  • :color (Boolean, String, nil) — default: nil

    color branches output

    Pass true for --color or a string ('always', 'never', 'auto') for --color=<when>.

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

    suppress colored output (--no-color)

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

    show sha1 and commit subject for each branch

    Pass true for --verbose (show sha1 and subject); pass 2 for --verbose --verbose (also show the linked worktree path and upstream branch name).

    Alias: :v

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

    minimum sha1 display length when used with verbose mode

    Pass an integer for --abbrev=<n> or true for --abbrev (default length).

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

    show full sha1s (--no-abbrev)

  • :column (Boolean, String, nil) — default: nil

    display branch listing in columns

    Pass true for --column or a string of options for --column=<options>. Only applicable in non-verbose mode.

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

    disable column output (--no-column)

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

    sort branches by the specified key(s)

    Give an array to add multiple --sort options. Prefix each key with '-' for descending order. For example, sort: ['refname', '-committerdate'].

  • :merged (Boolean, String, nil) — default: nil

    list only branches merged into the specified commit

    Pass true to default to HEAD or a commit ref string to filter by that commit.

  • :no_merged (Boolean, String, nil) — default: nil

    list only branches not merged into the specified commit

    Pass true to default to HEAD or a commit ref string to filter by that commit.

  • :contains (Boolean, String, nil) — default: nil

    list only branches that contain the specified commit

    Pass true to default to HEAD or a commit ref string to filter by that commit.

  • :no_contains (Boolean, String, nil) — default: nil

    list only branches that don't contain the specified commit

    Pass true to default to HEAD or a commit ref string to filter by that commit.

  • :points_at (String) — default: nil

    list only branches that point at the specified object

  • :format (String) — default: nil

    output format string for each branch

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

    list only remote-tracking branches

    Alias: :r

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

    list both local and remote branches

    Alias: :a

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

    sort and filter branches case insensitively

    Alias: :i

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

    do not print a newline after formatted refs where the format expands to the empty string

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/branch/list.rb', line 60