【发布时间】:2017-01-09 09:59:28
【问题描述】:
我正在使用 Capistrano (3.7.1) 将我的 Rails 5 应用程序部署到 VPS。我在 git 中使用了 2 个主要分支:master,用于稳定的生产就绪代码,develop,用于 WIP 代码。我想将develop 分支部署到临时服务器,但它似乎不起作用。
在deploy.rb:
# This is the failing task
task :check_revision do
on roles(:app) do
unless 'git rev-parse HEAD' == "git rev-parse origin/#{fetch(:branch)}"
puts "WARNING: HEAD is not the same as origin/#{fetch(:branch)}"
puts 'Run `git push` to sync changes.'
exit
end
end
end
在production.rb:
set :branch, 'master'
在staging.rb:
set :branch, 'develop'
每次尝试部署都失败,如下:
$ cap staging deploy
... initial steps, skipped over ...
WARNING: HEAD is not the same as origin/develop
Run `git push` to sync changes.
但显然情况并非如此,正如我得到的那样:
$ git rev-parse HEAD
38e4a194271780246391cf3977352cb7cb13fc86
$ git rev-parse origin/develop
38e4a194271780246391cf3977352cb7cb13fc86
显然是一样的。
发生了什么事?
【问题讨论】:
-
换行试试看:
unless `git rev-parse HEAD` == `git rev-parse origin/#{fetch(:branch)}`
标签: ruby-on-rails ruby git capistrano capistrano3