Class: Vlad::GitWithSubmoduleSupport
- Inherits:
-
Object
- Object
- Vlad::GitWithSubmoduleSupport
- Defined in:
- lib/if-vlad/git_with_submodule_support.rb
Constant Summary collapse
- VERSION =
based entirely upon the vlad-git gem.
"1.0"
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…)def etc…) Also inits and updates submodules.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/if-vlad/git_with_submodule_support.rb', line 14 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} checkout -f -b deployed-#{revision} #{revision}", "git submodule -q update --init", "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 Also checks out submodules.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/if-vlad/git_with_submodule_support.rb', line 33 def export(revision, destination) revision = 'HEAD' if revision =~ /head/i revision = "deployed-#{revision}" [ "mkdir -p #{destination}", "cd repo", "git-archive-all.sh #{application}.tar", "cat #{application}.tar | (cd #{destination} && tar xf -)", "rm -f #{application}.tar", "cd -", "cd .." ].join(" && ") end |
#revision(revision) ⇒ Object
Returns a command that maps human-friendly revision identifier revision
into a git SHA1.
51 52 53 54 55 |
# File 'lib/if-vlad/git_with_submodule_support.rb', line 51 def revision(revision) revision = 'HEAD' if revision =~ /head/i "`#{git_cmd} rev-parse #{revision}`" end |