我正在嘗試通過創建一個包含一些有用功能的包來自動化我的 Rmarkdown 作業流程。我希望能夠呼叫一個函式(例如,new_manuscript()),該函式將從我擁有的私有模板存盤庫中創建一個新專案。
使用該gh包,我可以輕松地創建一個新的存盤庫:
gh::gh("POST /user/repos", name = "test", private = "true")
但是,沒有可以在此 API 呼叫中傳遞的引數來指定模板存盤庫。我發現這個被稱為Github 應用程式createstructure似乎可以做我需要做的事情,但檔案對我來說并不完全清楚。
uj5u.com熱心網友回復:
r-lib/gh似乎不包括 API 呼叫“使用模板創建存盤庫”
正常的解決方法是使用gh api呼叫(gh()應該可以做到):
gh api \
--method POST \
-H "Accept: application/vnd.github.v3 json" \
/repos/TEMPLATE_OWNER/TEMPLATE_REPO/generate \
-f owner='octocat'
-f name='Hello-World'
-f description='This is your first repository'
-F include_all_branches=false
-F private=false
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/497138.html
標籤:r github github-api
