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
revision
from the code repo into directorydestination
. -
#export(source, destination) ⇒ Object
Returns the command that will export
revision
from the code repo 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 code repo 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 23 |
# File 'lib/vlad/git.rb', line 11 def checkout(revision, destination) destination = 'cached-copy' if destination == '.' revision = 'HEAD' if revision =~ /head/i [ "rm -rf #{destination}", "#{git_cmd} clone #{code_repo} #{destination}", "cd #{destination}", "#{git_cmd} fetch", "#{git_cmd} reset --hard #{revision}", "#{git_cmd} submodule init", "#{git_cmd} submodule update" ].join(" && ") end |
#export(source, destination) ⇒ Object
Returns the command that will export revision
from the code repo into the directory destination
.
29 30 31 32 33 |
# File 'lib/vlad/git.rb', line 29 def export(source, destination) [ "cp -R #{source} #{destination}", "rm -Rf #{destination}/.git" ].join(" && ") end |
#revision(revision) ⇒ Object
Returns a command that maps human-friendly revision identifier revision
into a git SHA1.
39 40 41 42 43 |
# File 'lib/vlad/git.rb', line 39 def revision(revision) revision = 'HEAD' if revision =~ /head/i "`#{git_cmd} rev-parse #{revision}`" end |