Class: E2B::Services::GitBranches

Inherits:
Object
  • Object
show all
Defined in:
lib/e2b/services/git.rb

Overview

Represents the branches in a git repository

Examples:

branches = sandbox.git.branches("/home/user/repo")
puts "Current: #{branches.current}"
puts "Local: #{branches.local.join(', ')}"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current: nil, local: [], remote: []) ⇒ GitBranches

Returns a new instance of GitBranches.

Parameters:

  • current (String, nil) (defaults to: nil)

    Current branch name

  • local (Array<String>) (defaults to: [])

    Local branch names

  • remote (Array<String>) (defaults to: [])

    Remote branch names



138
139
140
141
142
# File 'lib/e2b/services/git.rb', line 138

def initialize(current: nil, local: [], remote: [])
  @current = current
  @local = local
  @remote = remote
end

Instance Attribute Details

#currentString? (readonly)

Returns The currently checked-out branch.

Returns:

  • (String, nil)

    The currently checked-out branch



127
128
129
# File 'lib/e2b/services/git.rb', line 127

def current
  @current
end

#localArray<String> (readonly)

Returns List of local branch names.

Returns:

  • (Array<String>)

    List of local branch names



130
131
132
# File 'lib/e2b/services/git.rb', line 130

def local
  @local
end

#remoteArray<String> (readonly)

Returns List of remote branch names.

Returns:

  • (Array<String>)

    List of remote branch names



133
134
135
# File 'lib/e2b/services/git.rb', line 133

def remote
  @remote
end