Ruby on rails Capistrano:检查Git中的文件夹是否已更改?

Ruby on rails Capistrano:检查Git中的文件夹是否已更改?,ruby-on-rails,capistrano,capistrano3,Ruby On Rails,Capistrano,Capistrano3,我们的App1Repo有一个Rails后端和一个有角度的前端。因此,部署过程在某个点上有npm安装、bower安装和grunt构建强制。问题是部署需要很长时间,因为即使我们只是更新与Rails相关的东西,这些命令仍然会执行 是否有某种钩子,以便我可以检查包含前端代码的文件夹是否有更改,然后npm安装?或者我们应该将repo拆分为两个repo,每个repo都有自己的部署过程吗?插件为普通Rails资产提供了这样的功能 您可能需要检查代码并调整或复制粘贴代码以供使用 以下仅摘录相关步骤,并提供更多评

我们的App1Repo有一个Rails后端和一个有角度的前端。因此,部署过程在某个点上有npm安装、bower安装和grunt构建强制。问题是部署需要很长时间,因为即使我们只是更新与Rails相关的东西,这些命令仍然会执行

是否有某种钩子,以便我可以检查包含前端代码的文件夹是否有更改,然后npm安装?或者我们应该将repo拆分为两个repo,每个repo都有自己的部署过程吗?

插件为普通Rails资产提供了这样的功能

您可能需要检查代码并调整或复制粘贴代码以供使用

以下仅摘录相关步骤,并提供更多评论:

class PrecompileRequired < StandardError; end
begin
  # get the previous release
  latest_release = capture(:ls, '-xr', releases_path).split[1]

  # precompile if this is the first deploy
  raise PrecompileRequired unless latest_release

  # create a 'Pathname' object for latest_relase
  latest_release_path = releases_path.join(latest_release)

  # execute raises if there is a diff
  execute(:diff, '-Naur', release_path.join('path/to/frontend/code'), latest_release_path.join('path/to/frontend/code')) rescue raise(PrecompileRequired)

  info("Skipping asset precompile, no asset diff found")

  # copy over all of the assets from the last release
  execute(:cp, '-r', latest_release_path.join('public', fetch(:assets_prefix)), release_path.join('public', fetch(:assets_prefix)))

rescue PrecompileRequired
  # execute compile command here
end