Chef - 从 GitLab 克隆特定标签

Chef - Clone a specific tag from GitLab

我有这个片段,我应该从 git:

克隆一个 repo
git "somerepo" do
  action :sync
  destination "/var/"
  repository "http://#{node["somerepo"][:git_user]}:#{node["somerepo"][:git_pass]}@#{node["somerepo"][:git_host]}/#{node["somerepo"][:git_owner]}/somerepo.git"
  revision "#{node["somerepo"][:git_revision]}"
  user "root"
  group "root"
end

我在 GitLab 存储库中有这几个标签,名称如下: 12022015 01052016 02042016

我希望 tags/02042016 成为 cloned/checked 我在 SVN 中设置设置的方式。请帮忙。我有点搜索 Whosebug,我希望我只是忽略了以前的问题。如果这不可能,请提出建议。 :) 谢谢。

正如 documentation 所建议的,您可以为 revision 参数提供标签名称。

git "apt-cookbook" do
  repository "https://github.com/chef-cookbooks/apt"
  revision "v2.9.2"
  action :sync
end

由于 revision 参数的这种用法不是防弹的(不确定,当存在同名分支时会发生什么),您还可以提交完整的 Git refspec标签,即 refs/tags/<tagname>:

git "apt-cookbook" do
  repository "https://github.com/chef-cookbooks/apt"
  revision "refs/tags/v2.9.2"
  action :sync
end