class GitPlus::Commands::Branch

A Git branch command wrapper.

Public Class Methods

new(shell: Open3) click to toggle source
# File lib/git_plus/commands/branch.rb, line 9
def initialize shell: Open3
  @shell = shell
end

Public Instance Methods

call(*arguments) click to toggle source
# File lib/git_plus/commands/branch.rb, line 20
  def call(*arguments) = shell.capture3("git", "branch", *arguments)

  def name
    shell.capture3("git", "rev-parse", "--abbrev-ref", "HEAD").then do |stdout, stderr, status|
      status.success? ? stdout.chomp : stderr
    end
  end

  private

  attr_reader :shell
end
default() click to toggle source
# File lib/git_plus/commands/branch.rb, line 13
def default
  shell.capture3("git", "config", "init.defaultBranch").then do |stdout, _stderr, status|
    name = String stdout.chomp
    status.success? && !name.empty? ? name : "master"
  end
end
name() click to toggle source
# File lib/git_plus/commands/branch.rb, line 22
def name
  shell.capture3("git", "rev-parse", "--abbrev-ref", "HEAD").then do |stdout, stderr, status|
    status.success? ? stdout.chomp : stderr
  end
end