class Speedflow::Plugin::Git::Client

Git client

Attributes

git_client[W]

@return [Git::Client] Git client.

prompt[W]

@return [Prompt] Prompt.

Public Class Methods

new(config, prompt) click to toggle source

Initialize.

config - Speedflow::Plugin::Git::Configuration instance. prompt - Speedflow::Plugin::Git::Prompt instance.

Examples

Client.new({}, Speedflow::Plugin::Git::Prompt.new)
# => <Speedflow::Plugin::Git::Client>

Returns nothing.

# File lib/speedflow/plugin/git/client.rb, line 25
def initialize(config, prompt)
  @config = config
  @prompt = prompt
end

Public Instance Methods

branches(branch_type = :local) click to toggle source

Public: Branches.

branch_type - String of type (:local or :remote)

Returns Array of local branches.

# File lib/speedflow/plugin/git/client.rb, line 49
def branches(branch_type = :local)
  safe do
    git = git_client.open('.')
    git.branches.send(branch_type)
  end
end
create_branch(branch, branch_from) click to toggle source

Public: Create branch.

branch - Branch. branch_from - Branch from.

Returns Git::Branch.

# File lib/speedflow/plugin/git/client.rb, line 36
def create_branch(branch, branch_from)
  safe do
    git = git_client.open('.')
    git.branch(branch_from).checkout unless branch_from.empty?
    git.branch(branch).checkout
  end
end
git_client() click to toggle source

Public: Git client.

Returns ::Git instance.

# File lib/speedflow/plugin/git/client.rb, line 69
def git_client
  @git_client ||= ::Git
end
prompt() click to toggle source

Public: Prompt.

Returns ::Speedflow::Plugin::Git::Prompt instance.

# File lib/speedflow/plugin/git/client.rb, line 76
def prompt
  @prompt ||= ::Speedflow::Plugin::Git::Prompt.new
end
safe() { || ... } click to toggle source

Public: Safe process Git action.

Returns nothing.

# File lib/speedflow/plugin/git/client.rb, line 59
def safe
  yield
rescue StandardError => exception
  prompt.errors exception
  abort
end