[英]Can you get a repository's license in Gitlab through the REST API?
在Github中,當你建立一個項目時,你可以指定項目的許可,稍后可以在UI中查看,或者通過REST API獲取。
在 Gitlab 中是否可能發生同樣的事情? 我可以使用 Java 庫嗎? 我一直在瀏覽 REST API,但我似乎找不到這樣的東西。 在創建/設置存儲庫時似乎也無法配置它。
這可以通過在項目 API 中添加標志許可證來完成。
啟用此選項后,您將在響應 json 中獲得“license_url”和“license”。另外關於這個問題,將許可證文件放在文件夾中,而不是在您的根目錄中 - gitlab 會認為您沒有項目許可證,並且使用許可證標志獲取將為您提供 NULL。
許可證格式無關緊要,即使從模板創建並嘗試添加格式(.txt、.bat、.md 等)很困難,因為每個書面字符都會從 license_name 表單字段驅動,所以我認為大多數回購協議最終只有許可證。
例如從 gitlab-org/gitlab 存儲庫 (id 278964) 獲取許可證:
curl https://gitlab.com/api/v4/projects/278964?license=yes
回復:
{
"id": 278964,
"description": "GitLab is an open source end-to-end software development platform with built-in version control, issue tracking, code review, CI/CD, and more. Self-host GitLab on your own servers, in a container, or on a cloud provider.",
"name": "GitLab",
"name_with_namespace": "GitLab.org / GitLab",
...
"license_url": "https://gitlab.com/gitlab-org/gitlab/-/blob/master/LICENSE",
"license": {
"key": "other",
"name": "Other",
"nickname": "LICENSE",
"html_url": "http://choosealicense.com/licenses/other/",
"source_url": null
},
}
確實有一個GitLab API:
此處列出了所有客戶端,並且有一些Java客戶端: https : //about.gitlab.com/partners/#api-clients
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.