class DTK::Client::GitRepo
Wrapper around gem that does the git operations
Attributes
repo_dir[R]
Public Class Methods
clone(repo_url, target_path, branch)
click to toggle source
# File lib/client/git_repo.rb, line 37 def self.clone(repo_url, target_path, branch) git_adapter_class.clone(repo_url, target_path, branch) end
is_git_repo?(dir)
click to toggle source
# File lib/client/git_repo.rb, line 41 def self.is_git_repo?(dir) File.directory?("#{dir}/.git") end
modified?(dir)
click to toggle source
# File lib/client/git_repo.rb, line 52 def self.modified?(dir) repo_dir = { :path => dir, :branch => Git.open(dir).branches.local } message = DTK::Client::Operation::ClientModuleDir::GitRepo.modified(repo_dir) if message.data(:modified) raise Error::Usage, "Please push or revert changes." end end
modified_with_diff?(dir, opts = {})
click to toggle source
# File lib/client/git_repo.rb, line 63 def self.modified_with_diff?(dir, opts = {}) repo_dir = { :path => dir, :branch => Git.open(dir).branches.local, :command => opts[:command] } message = DTK::Client::Operation::ClientModuleDir::GitRepo.modified_with_diff(repo_dir) if message.data(:modified) error_msg = opts[:error_msg] || "To allow push to go through, use option '-f' or invoke 'dtk push' to push the changes before invoking stage again" raise Error::Usage, error_msg end end
new(repo_dir, opts = {})
click to toggle source
opts can have keys
:branch
# File lib/client/git_repo.rb, line 30 def initialize(repo_dir, opts = {}) @repo_dir = repo_dir @git_adapter = git_adapter_class.new(repo_dir, opts) end
unlink_local_clone?(dir)
click to toggle source
# File lib/client/git_repo.rb, line 45 def self.unlink_local_clone?(dir) git_dir = "#{dir}/.git" if File.directory?(git_dir) FileUtils.rm_rf(git_dir) end end
Private Class Methods
git_adapter_class()
click to toggle source
# File lib/client/git_repo.rb, line 187 def self.git_adapter_class Adapter::GitGem end
Public Instance Methods
add_all()
click to toggle source
# File lib/client/git_repo.rb, line 173 def add_all @git_adapter.add_all end
add_remote(name, url)
click to toggle source
# File lib/client/git_repo.rb, line 77 def add_remote(name, url) @git_adapter.add_remote(name, url) end
all_branches()
click to toggle source
# File lib/client/git_repo.rb, line 177 def all_branches @git_adapter.all_branches end
changed?()
click to toggle source
# File lib/client/git_repo.rb, line 81 def changed? @git_adapter.changed? end
checkout(branch, opts = {})
click to toggle source
opts can have keys
:new_branch - Boolean
# File lib/client/git_repo.rb, line 87 def checkout(branch, opts = {}) @git_adapter.checkout(branch, opts) end
current_branch()
click to toggle source
# File lib/client/git_repo.rb, line 91 def current_branch @git_adapter.current_branch end
diff()
click to toggle source
# File lib/client/git_repo.rb, line 95 def diff @git_adapter.diff end
diff_name_status(branch_or_sha_1 = nil, branch_or_sha_2 = nil, opts = {})
click to toggle source
# File lib/client/git_repo.rb, line 99 def diff_name_status(branch_or_sha_1 = nil, branch_or_sha_2 = nil, opts = {}) @git_adapter.diff_name_status(branch_or_sha_1, branch_or_sha_2, opts) end
empty_commit(commit_msg = nil)
click to toggle source
# File lib/client/git_repo.rb, line 149 def empty_commit(commit_msg = nil) @git_adapter.empty_commit(commit_msg) end
fetch(remote = 'origin')
click to toggle source
# File lib/client/git_repo.rb, line 103 def fetch(remote = 'origin') @git_adapter.fetch(remote) end
head_commit_sha()
click to toggle source
# File lib/client/git_repo.rb, line 107 def head_commit_sha @git_adapter.head_commit_sha end
is_there_remote?(remote_name)
click to toggle source
# File lib/client/git_repo.rb, line 111 def is_there_remote?(remote_name) @git_adapter.is_there_remote?(remote_name) end
local_ahead(base_sha, remote_sha)
click to toggle source
# File lib/client/git_repo.rb, line 169 def local_ahead(base_sha, remote_sha) @git_adapter.local_ahead(base_sha, remote_sha) end
merge(branch_to_merge_from, opts = {})
click to toggle source
# File lib/client/git_repo.rb, line 115 def merge(branch_to_merge_from, opts = {}) @git_adapter.merge(branch_to_merge_from, opts) end
print_status(opts = {})
click to toggle source
opts can have keys:
:with_diffs (Boolean)
# File lib/client/git_repo.rb, line 121 def print_status(opts = {}) @git_adapter.print_status(opts) end
pull(remote, branch)
click to toggle source
# File lib/client/git_repo.rb, line 133 def pull(remote, branch) @git_adapter.pull(remote, branch) end
push(remote, branch, opts = {})
click to toggle source
# File lib/client/git_repo.rb, line 125 def push(remote, branch, opts = {}) @git_adapter.push(remote, branch, opts) end
push_from_cached_branch(remote, branch, opts = {})
click to toggle source
# File lib/client/git_repo.rb, line 129 def push_from_cached_branch(remote, branch, opts = {}) @git_adapter.push_from_cached_branch(remote, branch, opts) end
remotes()
click to toggle source
# File lib/client/git_repo.rb, line 137 def remotes @git_adapter.remotes end
remove_remote(name)
click to toggle source
# File lib/client/git_repo.rb, line 141 def remove_remote(name) @git_adapter.remove_remote(name) end
reset_hard(sha)
click to toggle source
# File lib/client/git_repo.rb, line 157 def reset_hard(sha) @git_adapter.reset_hard(sha) end
reset_soft(sha)
click to toggle source
# File lib/client/git_repo.rb, line 153 def reset_soft(sha) @git_adapter.reset_soft(sha) end
rev_list(base_sha)
click to toggle source
# File lib/client/git_repo.rb, line 165 def rev_list(base_sha) @git_adapter.rev_list(base_sha) end
revparse(string)
click to toggle source
# File lib/client/git_repo.rb, line 161 def revparse(string) @git_adapter.revparse(string) end
stage_and_commit(commit_msg = nil)
click to toggle source
# File lib/client/git_repo.rb, line 145 def stage_and_commit(commit_msg = nil) @git_adapter.stage_and_commit(commit_msg) end
Private Instance Methods
git_adapter_class()
click to toggle source
# File lib/client/git_repo.rb, line 183 def git_adapter_class self.class.git_adapter_class end