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 code repo into directorydestination. -
#export(source, destination) ⇒ Object
Returns the command that will export
revisionfrom the code repo 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 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 |
# File 'lib/vlad/git.rb', line 11 def checkout(revision, destination) destination = 'cached-copy' if destination == '.' revision = 'HEAD' if revision =~ /head/i [ "([ -d #{destination}/.git ] && echo 'Existing repository found' || #{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.
28 29 30 31 32 |
# File 'lib/vlad/git.rb', line 28 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.
38 39 40 41 42 |
# File 'lib/vlad/git.rb', line 38 def revision(revision) revision = 'HEAD' if revision =~ /head/i "`#{git_cmd} rev-parse #{revision}`" end |