Class: Vlad::Git
- Inherits:
-
Object
- Object
- Vlad::Git
- Defined in:
- lib/vlad/git.rb
Instance Method Summary collapse
-
#checkout(revision, destination) ⇒ Object
Returns the command that will check out
revisionfrom the repository into directorydestination. -
#export(revision, destination) ⇒ Object
Returns the command that will export
revisionfrom the current directory into the directorydestination. -
#revision(revision) ⇒ Object
Returns a command that maps human-friendly revision identifier
revisioninto a git SHA1.
Instance Method Details
#checkout(revision, destination) ⇒ Object
Returns the command that will check out revision from the repository into directory destination. revision can be any SHA1 or equivalent (e.g. branch, tag, etc…)
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vlad/git.rb', line 11 def checkout(revision, destination) destination = File.join(destination, 'repo') revision = 'HEAD' if revision =~ /head/i [ "rm -rf #{destination}", "#{git_cmd} clone #{repository} #{destination}", "cd #{destination}", "#{git_cmd} submodule update --init", "#{git_cmd} checkout -f -b deployed-#{revision} #{revision}", "cd -" ].join(" && ") end |
#export(revision, destination) ⇒ Object
Returns the command that will export revision from the current directory into the directory destination. Expects to be run from scm_path after Vlad::Git#checkout
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vlad/git.rb', line 29 def export(revision, destination) revision = 'HEAD' if revision =~ /head/i revision = "deployed-#{revision}" [ "mkdir -p #{destination}", "cd repo", "#{git_cmd} archive --format=tar #{revision} | (cd #{destination} && tar xf -)", "#{git_cmd} submodule foreach '#{git_cmd} archive --format=tar $sha1 | (cd #{destination}/$path && tar xf -)'", "cd -", "cd .." ].join(" && ") end |
#revision(revision) ⇒ Object
Returns a command that maps human-friendly revision identifier revision into a git SHA1.
46 47 48 49 50 |
# File 'lib/vlad/git.rb', line 46 def revision(revision) revision = 'HEAD' if revision =~ /head/i "`#{git_cmd} rev-parse #{revision}`" end |