Module: Unwrappr::GitCommandRunner
- Defined in:
- lib/unwrappr/git_command_runner.rb
Overview
Runs Git commands
Class Method Summary collapse
- .clone_repository(repo, directory) ⇒ Object
- .commit_and_push_changes! ⇒ Object
- .create_branch!(base_branch:) ⇒ Object
- .current_branch_name ⇒ Object
- .file_exist?(filename) ⇒ Boolean
- .remote ⇒ Object
- .reset_client ⇒ Object
- .show(revision, path) ⇒ Object
Class Method Details
.clone_repository(repo, directory) ⇒ Object
39 40 41 |
# File 'lib/unwrappr/git_command_runner.rb', line 39 def clone_repository(repo, directory) git_wrap { Git.clone(repo, directory) } end |
.commit_and_push_changes! ⇒ Object
15 16 17 18 19 |
# File 'lib/unwrappr/git_command_runner.rb', line 15 def commit_and_push_changes! raise 'failed to add git changes' unless stage_all_changes raise 'failed to commit changes' unless commit_staged_changes raise 'failed to push changes' unless push_current_branch_to_origin end |
.create_branch!(base_branch:) ⇒ Object
10 11 12 13 |
# File 'lib/unwrappr/git_command_runner.rb', line 10 def create_branch!(base_branch:) raise 'Not a git working dir' unless git_dir? raise "failed to create branch from '#{base_branch}'" unless checkout_target_branch(base_branch: base_branch) end |
.current_branch_name ⇒ Object
35 36 37 |
# File 'lib/unwrappr/git_command_runner.rb', line 35 def current_branch_name git.current_branch end |
.file_exist?(filename) ⇒ Boolean
43 44 45 |
# File 'lib/unwrappr/git_command_runner.rb', line 43 def file_exist?(filename) !git.ls_files(filename).empty? end |
.remote ⇒ Object
31 32 33 |
# File 'lib/unwrappr/git_command_runner.rb', line 31 def remote git.config('remote.origin.url') end |
.reset_client ⇒ Object
21 22 23 |
# File 'lib/unwrappr/git_command_runner.rb', line 21 def reset_client @git = nil end |
.show(revision, path) ⇒ Object
25 26 27 28 29 |
# File 'lib/unwrappr/git_command_runner.rb', line 25 def show(revision, path) git.show(revision, path) rescue Git::GitExecuteError nil end |