我正在使用 bundler 将内部 git 存储库中的 gem 部署到我的 rails 应用程序中。我想为不同的组设置不同的分支名称,但是,这个:
group :production, :release_candidate, :staging, :demo do
gem "my_inhouse_gem", '0.0.1', git: 'git@github.com:my_gem.git', branch: 'master'
end
group :development, :develop do
gem "my_inhouse_gem", '0.0.1', git: 'git@github.com:my_gem.git', branch: 'develop'
end
失败了
You cannot specify the same gem twice coming from different sources.
You specified that mygem (= 0.0.1) should come from
git@github.com:my_gem.git (at develop) and
git@github.com:my_gem.git (at master)
而以下:
group :production, :release_candidate, :staging, :demo do
my_gem = 'master'
end
group :development, :develop do
my_gem = "develop"
end
gem "my_inhouse_gem", '0.0.1', git: 'git@github.com:my_gem.git', branch: my_gem
只需使用最后打印的组。
在阅读并找到这篇文章后:http: //yehudakatz.com/2010/05/09/the-how-and-why-of-bundler-groups/,我意识到这是因为捆绑器仍然会执行内容每个组,然后只需安装匹配的组。
如何根据 Gemfile 中的环境配置获得动态分支名称?