classVlad::Git
set :source,Vlad::Git.new
set :git_cmd,"git"##
# 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...)
defcheckout(revision, destination)
destination ='repo'if destination =='.'
revision ='HEAD'if revision =~/head/i# Clone from scratch or update the existing copy of the repository.
## NOTE Requires source.checkout to be run separately from other commands
# since 'if' can't be joined with && to other shell commands.
["if [ -d #{destination}/.git ]","then cd #{destination} && #{git_cmd} checkout -f -b deployed-#{revision}#{revision}","else #{git_cmd} clone #{repository}#{destination}","fi"].join(" ; ")end##
# Returns the command that will export +revision+ from the repository into
# the directory +destination+.
## TODO Assumes that checkout will handle the appropriate version.
defexport(revision_or_source, destination)
source_dir ='repo'if revision_or_source =='.'
revision_name = revision_or_source
revision_name ='HEAD'if revision_or_source =="."["cd #{source_dir}","mkdir -p #{destination}","#{git_cmd} archive --format=tar #{revision_name} | (cd #{destination} && tar xf -)"].join(" && ")end##
# Returns a command that maps human-friendly revision identifier +revision+
# into a git SHA1.
defrevision(revision)
revision ='HEAD'if revision =~/head/i"`#{git_cmd} rev-parse #{revision}`"endend