Skip to content

Instantly share code, notes, and snippets.

@jkraemer
Created July 28, 2010 14:47
Show Gist options
  • Save jkraemer/494750 to your computer and use it in GitHub Desktop.
Save jkraemer/494750 to your computer and use it in GitHub Desktop.
git.rb | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
--- ./capistrano/recipes/deploy/scm/git.rb.orig
+++ ./capistrano/recipes/deploy/scm/git.rb
@@ -157,10 +157,26 @@
execute.join(" && ")
end
- # An expensive export. Performs a checkout as above, then
- # removes the repo.
+ # use git archive to export repository
def export(revision, destination)
- checkout(revision, destination) << " && rm -Rf #{destination}/.git"
+ git = command
+ execute = []
+ args = []
+
+ args << '--format=tar'
+ args << "--remote=#{configuration[:repository]}"
+ if project = configuration[:project]
+ args << "#{revision}:#{project}"
+ else
+ args << revision
+ end
+
+ # export (using git archive)
+ execute << "mkdir -p #{destination}"
+ execute << "cd #{destination}"
+ execute << "#{git} archive #{args.join(' ')} | tar xf -"
+
+ execute.join(" && ")
end
# Merges the changes to 'head' since the last fetch, for remote_cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment