Bryan,

That's a neat idea. I like the side benefit of letting subdirectories be
deployed, too. Could you post that patch on the capistrano lighthouse
(http://capistrano.lighthouseapp.com/projects/8716-capistrano/tickets)
so that it doesn't get lost?

- Jamis

On 1/17/09 7:19 PM, Bryan Cardillo wrote:
> Hi all,
> 
> I'd like to suggest an alternate implementation for export in the git
> scm class.  Currently, git export performs a clone and checkout (just
> like checkout), then removes the .git directory.  I think git archive
> is better suited for this since it doesn't require transferring the
> entire repository.  As an added bonus, you can specify paths within
> the repository to the archive command, allowing specific directories
> to be deployed (a feature I've seen requested from time to time, and
> my original motivation for ever looking at the git scm code).  Anyway,
> I've been using my patched git class for a bit now, and thought I'd
> offer it here in case others find it useful.
> 
> Cheers,
> Bryan
> 
>  git.rb |   22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> --- src/ruby/capistrano/recipes/deploy/scm/git.rb.orig
> +++ src/ruby/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
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to