class Dapp::Dimg::GitRepo::Remote
Constants
- CACHE_VERSION
Attributes
url[R]
Public Class Methods
get_or_create(dapp, name, url:)
click to toggle source
# File lib/dapp/dimg/git_repo/remote.rb, line 10 def get_or_create(dapp, name, url:) repositories[url] ||= new(dapp, name, url: url).tap(&:clone_and_fetch) end
new(dapp, name, url:)
click to toggle source
Calls superclass method
Dapp::Dimg::GitRepo::Base::new
# File lib/dapp/dimg/git_repo/remote.rb, line 19 def initialize(dapp, name, url:) super(dapp, name) @url = url end
repositories()
click to toggle source
# File lib/dapp/dimg/git_repo/remote.rb, line 14 def repositories @repositories ||= {} end
Public Instance Methods
_rugged_credentials()
click to toggle source
# File lib/dapp/dimg/git_repo/remote.rb, line 52 def _rugged_credentials # TODO remove @_rugged_credentials ||= begin if url_protocol(url) == :ssh host_with_user = url.split(':', 2).first username = host_with_user.split('@', 2).reverse.last Rugged::Credentials::SshKeyFromAgent.new(username: username) end end end
clone_and_fetch()
click to toggle source
# File lib/dapp/dimg/git_repo/remote.rb, line 66 def clone_and_fetch return ruby2go_method("CloneAndFetch") end
get_ruby2go_state_hash()
click to toggle source
Calls superclass method
Dapp::Dimg::GitRepo::Base#get_ruby2go_state_hash
# File lib/dapp/dimg/git_repo/remote.rb, line 39 def get_ruby2go_state_hash super.tap {|res| res["Url"] = @url.to_s res["ClonePath"] = dapp.build_path("remote_git_repo", CACHE_VERSION.to_s, dapp.consistent_uniq_slugify(name), url_protocol(url)).to_s # FIXME res["IsDryRun"] = dapp.dry_run? } end
lookup_commit(commit)
click to toggle source
Calls superclass method
Dapp::Dimg::GitRepo::Base#lookup_commit
# File lib/dapp/dimg/git_repo/remote.rb, line 70 def lookup_commit(commit) super rescue Rugged::OdbError, TypeError => _e raise Error::Rugged, code: :commit_not_found_in_remote_git_repository, data: { commit: commit, url: url } end
path()
click to toggle source
# File lib/dapp/dimg/git_repo/remote.rb, line 62 def path Pathname(dapp.build_path("remote_git_repo", CACHE_VERSION.to_s, dapp.consistent_uniq_slugify(name), url_protocol(url)).to_s) end
ruby2go_method(method, args_hash={})
click to toggle source
# File lib/dapp/dimg/git_repo/remote.rb, line 29 def ruby2go_method(method, args_hash={}) res = dapp.ruby2go_git_repo(args_hash.merge("RemoteGitRepo" => JSON.dump(get_ruby2go_state_hash), "method" => method)) raise res["error"] if res["error"] self.set_ruby2go_state_hash(JSON.load(res["data"]["RemoteGitRepo"])) res["data"]["result"] end
set_ruby2go_state_hash(state)
click to toggle source
Calls superclass method
Dapp::Dimg::GitRepo::Base#set_ruby2go_state_hash
# File lib/dapp/dimg/git_repo/remote.rb, line 47 def set_ruby2go_state_hash(state) super(state) @url = state["Url"] end
Protected Instance Methods
git()
click to toggle source
Calls superclass method
Dapp::Dimg::GitRepo::Base#git
# File lib/dapp/dimg/git_repo/remote.rb, line 78 def git # TODO remove super(bare: true, credentials: _rugged_credentials) end
Private Instance Methods
branch_format(name)
click to toggle source
# File lib/dapp/dimg/git_repo/remote.rb, line 94 def branch_format(name) # TODO remove "origin/#{name.reverse.chomp('origin/'.reverse).reverse}" end
url_protocol(url)
click to toggle source
# File lib/dapp/dimg/git_repo/remote.rb, line 84 def url_protocol(url) # TODO remove if (scheme = URI.parse(url).scheme).nil? :noname else scheme.to_sym end rescue URI::InvalidURIError :ssh end