Class: Speedflow::Plugin::Git::Client
- Inherits:
-
Object
- Object
- Speedflow::Plugin::Git::Client
- Defined in:
- lib/speedflow/plugin/git/client.rb
Overview
Git client
Instance Attribute Summary collapse
-
#git_client ⇒ Object
Public: Git client.
-
#prompt ⇒ Object
Public: Prompt.
Instance Method Summary collapse
-
#branches(branch_type = :local) ⇒ Object
Public: Branches.
-
#create_branch(branch, branch_from) ⇒ Object
Public: Create branch.
-
#initialize(config, prompt) ⇒ Client
constructor
Initialize.
-
#safe ⇒ Object
Public: Safe process Git action.
Constructor Details
#initialize(config, prompt) ⇒ Client
25 26 27 28 |
# File 'lib/speedflow/plugin/git/client.rb', line 25 def initialize(config, prompt) @config = config @prompt = prompt end |
Instance Attribute Details
#git_client ⇒ Object
Public: Git client.
Returns ::Git instance.
69 70 71 |
# File 'lib/speedflow/plugin/git/client.rb', line 69 def git_client @git_client ||= ::Git end |
Instance Method Details
#branches(branch_type = :local) ⇒ Object
Public: Branches.
branch_type - String of type (:local or :remote)
Returns Array of local branches.
49 50 51 52 53 54 |
# 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) ⇒ Object
Public: Create branch.
branch - Branch. branch_from - Branch from.
Returns Git::Branch.
36 37 38 39 40 41 42 |
# 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 |
#safe ⇒ Object
Public: Safe process Git action.
Returns nothing.
59 60 61 62 63 64 |
# File 'lib/speedflow/plugin/git/client.rb', line 59 def safe yield rescue StandardError => exception prompt.errors exception abort end |