Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created August 5, 2009 02:34
Show Gist options
  • Save defunkt/162448 to your computer and use it in GitHub Desktop.
Save defunkt/162448 to your computer and use it in GitHub Desktop.
##
# 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 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}",
"cd -"
].join(" && ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment