Skip to content

Instantly share code, notes, and snippets.

@jkraemer
Created July 28, 2010 14:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jkraemer/494755 to your computer and use it in GitHub Desktop.
Save jkraemer/494755 to your computer and use it in GitHub Desktop.
lib/cap-git-archive.rb:
-------------------------------------------------
require 'capistrano/recipes/deploy/scm/git'
Capistrano::Deploy::SCM::Git.class_eval do
def export(revision, destination)
git = command
execute = []
args = []
args << '--format=tar'
args << "--remote=#{configuration[:repository]}"
if app_root = configuration[:app_root]
args << "#{revision}:#{app_root}"
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
end
-------------------------------------------------
config/deploy.rb:
-------------------------------------------------
load 'lib/cap-git-archive.rb'
set :scm, :git
set :deploy_via, :copy
set :copy_strategy, :export # obige export-methode verwenden (per default macht er 'nen checkout)
set :app_root, 'serviceportal' # das ist der Pfad innerhalb des repositories, der exportiert werden soll
-------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment