Class: Git::Commands::Branch::ShowCurrent Private

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

Prints the name of the current branch. In detached HEAD state, nothing is printed.

Examples:

Print the current branch name

show_current = Git::Commands::Branch::ShowCurrent.new(execution_context)
result = show_current.call
puts result.stdout  # => "main\n"

Check for detached HEAD state

show_current = Git::Commands::Branch::ShowCurrent.new(execution_context)
result = show_current.call
# result.stdout is empty ("") when in detached HEAD state

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

#callGit::CommandLineResult

Execute the git branch --show-current command.

Returns:

Raises:



# File 'lib/git/commands/branch/show_current.rb', line 37