Class: Bixby::Provision::SCM::Git
- Defined in:
- lib/bixby/provision/dsl/scm/git.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#get_gid, #get_group, #get_uid, #get_user, #initialize, #tap, #tempfile
Methods included from Util::File
#chmod, #chown, #sha256sum, #which
Constructor Details
This class inherits a constructor from Bixby::Provision::Base
Instance Method Details
#checkout(uri, opts) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bixby/provision/dsl/scm/git.rb', line 8 def checkout(uri, opts) path = opts.delete(:path) branch = opts.delete(:branch) || "master" if path.nil? then # TODO raise end path = File.(path) if File.directory? File.join(path, ".git") then logger.info "repository already checked out at #{path}" return end dir.create(path) # https://github.com/user/repo.git # [email protected]:user/repo.git # ssh://[email protected]/user/repo if uri !~ %r{https?://} && uri =~ %r{^(ssh://)?(.*?@)(.*?)[:/]} then ensure_ssh_verify($3) end sys.package "git" require "git" # lazy require here, because loading will try to run `git --version` logger.info "[scm] cloning #{uri} into #{path}, branch: #{branch}" g = ::Git.clone(uri, File.basename(path), :path => File.dirname(path)) g.checkout(branch) if branch != "master" end |