在Capistrano中部署Git子目录 [英] Deploying a Git subdirectory in Capistrano

查看:117
本文介绍了在Capistrano中部署Git子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主分支布局是这样的:

My master branch layout is like this:

/ < - 顶级

/ <-- top level

/ client < - 桌面客户端源文件

/client <-- desktop client source files

/ server Rails应用程序

/server <-- Rails app

我想做的只是在我的 deploy.rb 中拉下/ server目录,但我似乎找不到任何办法。 / client目录是巨大的,所以设置一个钩子来复制/服务器/将不会很好,它只需要拉下Rails应用程序。

What I'd like to do is only pull down the /server directory in my deploy.rb, but I can't seem to find any way to do that. The /client directory is huge, so setting up a hook to copy /server to / won't work very well, it needs to only pull down the Rails app.

推荐答案

没有任何脏的分拣行动,但更脏!

Without any dirty forking action but even dirtier !

在我的config / deploy.rb:

In my config/deploy.rb :

set :deploy_subdir, "project/subdir"

然后我将这个新策略添加到我的Capfile中:

Then I added this new strategy to my Capfile :

require 'capistrano/recipes/deploy/strategy/remote_cache'

class RemoteCacheSubdir < Capistrano::Deploy::Strategy::RemoteCache

  private

  def repository_cache_subdir
    if configuration[:deploy_subdir] then
      File.join(repository_cache, configuration[:deploy_subdir])
    else
      repository_cache
    end
  end

  def copy_repository_cache
    logger.trace "copying the cached version to #{configuration[:release_path]}"
    if copy_exclude.empty? 
      run "cp -RPp #{repository_cache_subdir} #{configuration[:release_path]} && #{mark}"
    else
      exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ')
      run "rsync -lrpt #{exclusions} #{repository_cache_subdir}/* #{configuration[:release_path]} && #{mark}"
    end
  end

end


set :strategy, RemoteCacheSubdir.new(self)

这篇关于在Capistrano中部署Git子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆