Class: OxenDeployer::Git
- Inherits:
-
Object
- Object
- OxenDeployer::Git
- Defined in:
- lib/oxen_deployer/git.rb
Constant Summary collapse
- VERSION =
Duh.
"1.0.7"
Instance Method Summary collapse
-
#checkout(revision, destination) ⇒ Object
Returns the command that will check out
revision
from the repository into directorydestination
. -
#export(revision, destination) ⇒ Object
Returns the command that will export
revision
from the current directory into the directorydestination
. -
#revision(revision) ⇒ Object
Returns a command that maps human-friendly revision identifier
revision
into 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…)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/oxen_deployer/git.rb', line 13 def checkout(revision, destination) destination = File.join(destination, 'repo') revision = 'HEAD' if revision =~ /head/i new_revision = ('HEAD' == revision) ? "origin" : revision [ "cd #{destination}", "#{git_cmd} checkout #{revision}", "#{git_cmd} branch -D deployed-#{revision}", "#{git_cmd} pull", "#{git_cmd} branch deployed-#{revision} #{revision}", "#{git_cmd} checkout deployed-#{revision}", "cd -" ].join( " && ") # if fast_checkout_applicable?(revision, destination) # [ "cd #{destination}", # "#{git_cmd} checkout #{revision}", # "#{git_cmd} fetch", # "#{git_cmd} reset --hard #{new_revision}", # submodule_cmd, # "#{git_cmd} branch -D deployed-#{revision}", # "#{git_cmd} branch deployed-#{revision} #{revision}", # "#{git_cmd} checkout deployed-#{revision}", # "cd -" # ].join(" && ") # # [ "cd #{destination}", # # "#{git_cmd} checkout -q origin", # # "#{git_cmd} fetch", # # "#{git_cmd} reset --hard #{new_revision}", # # submodule_cmd, # # "#{git_cmd} branch -f deployed-#{revision} #{revision}", # # "#{git_cmd} checkout deployed-#{revision}", # # "cd -" # # ].join(" && ") # else # [ "rm -rf #{destination}", # "mkdir -p #{destination}", # "cd #{destination}", # "#{git_cmd} init", # "#{git_cmd} remote add -t #{revision} -f origin #{repository}", # "#{git_cmd} checkout #{revision}", # "#{git_cmd} branch -D deployed-#{revision}", # "#{git_cmd} checkout -b deployed-#{revision}", # submodule_cmd, # "cd -" # ].join(" && ") # # # # # # [ "rm -rf #{destination}", # # "#{git_cmd} clone #{repository} #{destination}", # # "cd #{destination}", # # "#{git_cmd} checkout -f -b deployed-#{revision} #{revision}", # # submodule_cmd, # # "cd -" # # ].join(" && ") # end 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.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/oxen_deployer/git.rb', line 74 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.
90 91 92 93 94 |
# File 'lib/oxen_deployer/git.rb', line 90 def revision(revision) revision = 'HEAD' if revision =~ /head/i "`#{git_cmd} rev-parse #{revision}`" end |