lib/unwrappr/git_command_runner.rb in unwrappr-0.3.1 vs lib/unwrappr/git_command_runner.rb in unwrappr-0.3.2

- old
+ new

@@ -34,10 +34,18 @@ def current_branch_name git.current_branch end + def clone_repository(repo, directory) + git_wrap { Git.clone(repo, directory) } + end + + def file_exist?(filename) + !git.ls_files(filename).empty? + end + private def git_dir? git_wrap { !current_branch_name.empty? } end @@ -61,14 +69,20 @@ def git_pushed? git_wrap { git.push('origin', current_branch_name) } end def git - log_options = {}.tap do |opt| - opt[:log] = Logger.new(STDOUT) if ENV['DEBUG'] + if Dir.pwd == @git&.dir&.path + @git + else + Git.open(Dir.pwd, log_options) end + end - @git ||= Git.open(Dir.pwd, log_options) + def log_options + {}.tap do |opt| + opt[:log] = Logger.new(STDOUT) if ENV['DEBUG'] + end end def git_wrap yield true