Class: Gitt::Commands::Branch

Inherits:
Object
  • Object
show all
Defined in:
lib/gitt/commands/branch.rb

Overview

A Git branch command wrapper.

Instance Method Summary collapse

Constructor Details

#initialize(shell: SHELL) ⇒ Branch

Returns a new instance of Branch.



7
8
9
# File 'lib/gitt/commands/branch.rb', line 7

def initialize shell: SHELL
  @shell = shell
end

Instance Method Details

#call(*arguments) ⇒ Object



17
# File 'lib/gitt/commands/branch.rb', line 17

def call(*arguments) = shell.call "branch", *arguments

#defaultObject



11
12
13
14
15
# File 'lib/gitt/commands/branch.rb', line 11

def default
  shell.call("config", "init.defaultBranch")
       .fmap(&:chomp)
       .fmap { |name| name.empty? ? "main" : name }
end

#nameObject



19
# File 'lib/gitt/commands/branch.rb', line 19

def name = shell.call("rev-parse", "--abbrev-ref", "HEAD").fmap(&:chomp)