2

我正在努力使用 git API 访问我的 git 文件。

curl -v -H "授权:令牌 111111111111111111111111111" -H "接受:application/vnd.github.v3.raw+json" -i
https:// MYDOMAIN /api/v3/repos/ MYOWNERNAME / MYREPOSITORY /git/blobs/ {文件 sha 值}

我得到的错误

{“消息”:“未找到”,“documentation_url”:“https://developer.github.com/enterprise/2.20/v3/git/blobs/#get-a-blob”}

  • 与主机MYDOMAIN的连接 #0保持不变

我们正在使用 GitHub Enterprise 解决方案。

  1. 我不确定我是否也输入了正确的文件 SHA 值。反正有没有得到正确的 SHA 值?

  2. 有没有人用这种方式访问​​ git 文件?

4

1 回答 1

0

我对 GitHub Enterprise 没有任何经验,但我能够对公共存储库执行以下 cURL 请求:

curl https://api.github.com/repos/msbit/tools/git/blobs/a6628025e73c505a07305fd25507d0736725474d

回复如下:

{
  "sha": "a6628025e73c505a07305fd25507d0736725474d",
  "node_id": "MDQ6QmxvYjEyMzQwMzg5OmE2NjI4MDI1ZTczYzUwNWEwNzMwNWZkMjU1MDdkMDczNjcyNTQ3NGQ=",
  "size": 1575,
  "url": "https://api.github.com/repos/msbit/tools/git/blobs/a6628025e73c505a07305fd25507d0736725474d",
  "content": "IyBUb29scwoKQSBncmFiIGJhZyBvZiBCYXNoIHNjcmlwdHMgdGhhdCBJIGhh\ndmUgdXNlZCBvZnRlbiBlbm91Z2ggdG8gZmluZCBzZW1pLXVzZWZ1bAoKIyMg\nQmFja3VwIEFQSwoKICAgIGJhY2t1cC1hcGsuc2gKCkJhY2t1cCBhbGwgQVBL\nIGZpbGVzIGZyb20gYW4gYXR0YWNoZWQgQW5kcm9pZCBkZXZpY2UuCgojIyBC\ndW5kbGUgVXBkYXRlcwoKICAgIGJ1bmRsZS11cGRhdGVzLnNoCgpSdW4gQnVu\nZGxlIHVwZGF0ZSBpbiBhIFJ1YnkgcHJvamVjdCwgZGV0ZXJtaW5lIHRoZSBh\ncHByb3ByaWF0ZSBkaXJlY3QgYW5kIHRyYW5zaXRpdmUgZGVwZW5kZ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dGNoCgogICAgc2NyYXRjaC5zaAoKT3BlbiBhIG5ldyBzaGVsbCBpbnN0\nYW5jZSBpbiBhIHRlbXBvcmFyeSBzY3JhdGNoIGRpcmVjdG9yeSwgYW5kIGNs\nZWFuIHVwIHRoZSBkaXJlY3Rvcnkgb25jZSB0aGUgc2hlbGwgaGFzIGNsb3Nl\nZC4KCiMjIFN0cmlwIEpBUgoKICAgIHN0cmlwLWphci5zaAoKVW5wYWNrIGEg\nSkFSIGZpbGUgYW5kIGNyZWF0ZSBhbiB1cGRhdGVkIEpBUiBmaWxlIHdpdGgg\ndGhlIHNwZWNpZmllZCBjbGFzc2VzL3BhY2thZ2VzIHJlbW92ZWQuCgojIyBV\ncGRhdGUgRHJ1cGFsCgogICAgdXBkYXRlLWRydXBhbC5zaAoKUGVyZm9ybSBh\nbiBhcHByb3ByaWF0ZSBzZXF1ZW5jZSBvZiBgZHJ1c2hgIGNvbW1hbmRzIHRv\nIHByb3Blcmx5IHVwZGF0ZSBEcnVwYWwuCgojIyBWZXJzaW9uIEFQSwoKICAg\nIHZlcnNpb24tYXBrLnNoCgpQcmludCBvdXQgdGhlIHBhY2thZ2UsIHZlcnNp\nb24gYW5kIHZlcnNpb24gY29kZSBvZiBhIHNwZWNpZmllZCBBUEsgZmlsZS4K\n",
  "encoding": "base64"
}

所以也许您正在寻找的 URL 的路径应该是(删除/api/v3部分):

https://MYDOMAIN/repos/MYOWNERNAME/MYREPOSITORY/git/blobs/{file sha value}
于 2020-08-24T06:19:30.247 回答