上下文:我有一个附加了mongo db的节点应用程序。 db包括2个结构,表示文件/文件夹系统。基本上,具有表示文件夹的树结构,以及表示文件的内容结构。
我的想法是使用js包装器为GitHub api(希望如此)将它放入GitHub。
问题:我不太了解GitHub API如何接受这些信息。
git init
开始,设置git开始。git init
步骤?有人可以解释这是如何映射到看起来像这样的工作流程:
关于文件夹如何工作的一点让我感到困惑 任何指针都将非常受欢迎。
答案 0 :(得分:0)
DVCS (Decentralized VCS)背后的想法是你需要将本地提交发布到远程仓库。
因此,虽然您需要GitHub API来创建远程仓库,但您只需要Git(而不是GitHub API)在本地添加和提交,然后push to the remote。
答案 1 :(得分:0)
使用GitHub API创建存储库 备注
如何使用以上信息: (1)从Meteor(我的用例)创建一个新的仓库。
export const insertRepo = new ValidatedMethod({ name: 'repos.insert', validate: RepoSchema.validator(), run({ repoGeneralSettings, }) { if (Meteor.isServer) { const method = 'POST'; const url = 'https://api.github.com/user/repos'; const token = Meteor.settings.private.github.token; const headers = { 'User-Agent': 'Meteor/1.0', 'Authorization': token, }; const data = repoGeneralSettings; return HTTP.call(method, url, { headers, data }); } }, });
(2)这看起来像:
POST /user/repos HTTP/1.1 Host: api.github.com Authorization: Cache-Control: no-cache Postman-Token: 39be029f-817e-62fb-c07b-3fedf69200d4 { "name": "TestRepo1", "description": "This is a test repository", "homepage": "https://www.example.com", "private": false, "has_issues": false, "has_wiki": false, "has_downloads": true, "auto_init": true }
(3)并将返回201,如此:https://developer.github.com/v3/repos/#response-2
(4)删除也很simple。请注意,根据此comment,与令牌相关的api中的授权(非常明显)。这导致了一些问题,因为我一直在尝试更改所有者的权限,当需要发生的是授权令牌的更改权限时。忽略以下设置,不要尝试在createRepo调用中设置它们。