Public 使用命令行 Git 回购的可见性

Public visibility of Git repo using command line

我有一个ruby的脚本,可以使用命令行(和GitLab API)创建一个Git仓库,它也可以实现提交和推送,但我的问题是创建的存储库具有私有可见性,因此我如何更改可见性?

以及如何使用命令行将创建的存储库添加到组中?

这是我在 Github 中的脚本:https://github.com/ivanove/my_works/blob/master/Create-Repo.rb

这是create_repo的方法:

def crete_repo(name)
  puts "Creating Git repository #{name}...".blue
  cmd = "curl -H \"Content-Type:application/json\" http://#{@host}/api/v3/projects?private_token=#{@token} -d '{\"name\":\"#{name}\"}'"
  puts cmd
  system(cmd)
  puts "done."
end

visibility_level = 20 添加到您的请求参数中(参见 documentation)。那将在您的 create_repo 方法中。

此外,考虑使用 GitLab 客户端而不是 运行 从命令行卷曲。例如,this one.