是否可以通过 Github API 来判断提交是否是合并提交?它是从哪个分支合并的?
我试图查看在比较分支上的两个提交时更改的所有文件,但我想忽略从其分支的分支合并提交所做的任何更改。任何从该分支分支出来的分支都不会忽略其合并提交。
我想使用 Pygithub 将图像文件上传到我的 Github 存储库。
from github import Github
g=Github("My Git Token")
repo=g.get_repo("My Repo")
content=repo.get_contents("")
f=open("1.png")
img=f.read()
repo.create_file("1.png","commit",img)
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
File "c:\Users\mjjha\Documents\Checkrow\tempCodeRunnerFile.py", line 10, in <module>
img=f.read()
File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 119: character maps to <undefined>
Run Code Online (Sandbox Code Playgroud)
此方法对于文本文件效果很好。但我无法将图像文件上传到我的存储库。
当我使用 open-CV 读取图像文件时,出现以下错误:
assert isinstance(content, (str, bytes))
AssertionError
Run Code Online (Sandbox Code Playgroud)
我使用 cv2 时的代码是:
from github import Github
import cv2
g=Github("")
repo=g.get_repo("")
content=repo.get_contents("")
f=cv2.imread("1.png")
img=f
repo.create_file("1.png","commit",img)
Run Code Online (Sandbox Code Playgroud)
我认为 createFile() 仅将字符串作为参数,因此会出现这些错误。
有没有办法使用 Pygithub(或任何库)将图像文件上传到 Github?
当使用github cli api通过 git-bash 终端读取拉取请求数据时,出现“gh: Not Found (HTTP 404)”错误。当我通过 PowerShell 终端或 wsl 运行完全相同的脚本时,效果很好。知道为什么会发生这种情况吗?
我有一个用例,我必须重复运行 github 搜索 API。但是有时在这之间我会收到以下错误:
"API rate limit exceeded for user ID XXXXX".
Run Code Online (Sandbox Code Playgroud)
我怎样才能避免这个错误?有什么办法吗?
现在,一些标准 GitHub 操作已存档并且不再受支持,我需要创建一个新版本并使用GitHub 脚本操作上传工件。
注意:我无法使用 GitHub 不支持的操作。
我已经完成了发布并正在工作,但是现在当尝试上传发布工件时,我找不到上传发布内容(这是一个 tarball)的方法。
用于上传发布资产的 API 端点的文档建议数据应该是调用输入的一部分,而不是引用文件。
如何将文件的内容获取到下面的数据参数中:
- name: Upload Assets
uses: "actions/github-script@v6"
with:
script: |
try {
return await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
name: "release.tar.xz",
release_id: ${{ fromJSON(steps.deploy.outputs.result).data.id }}
data:
})
} catch (error) {
core.setFailed(error.message);
}
Run Code Online (Sandbox Code Playgroud) 使用curl http://github.com/api/v2/json/user/show/username github的用户api返回:
...,"login":"myUsername","email":"myEmail@test.com"}}**1**
Run Code Online (Sandbox Code Playgroud)
为什么json之后会有1?这是他们的错误,还是应该用于什么?
<?php
function getGithub($url="user/show/username") {
$github = curl_init();
curl_setopt($github, CURLOPT_URL, "http://github.com/api/v2/json/". $url);
return curl_exec($github);
}
Run Code Online (Sandbox Code Playgroud)
尝试去
echo getGithub();
Run Code Online (Sandbox Code Playgroud)
但由于最后有1,我必须这样做
echo rtrim(getGithub(), "1");
Run Code Online (Sandbox Code Playgroud) [
{
"url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"commit": {
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"author": {
"name": "Monalisa Octocat",
"email": "support@github.com",
"date": "2011-04-14T16:00:49Z"
},
"committer": {
"name": "Monalisa Octocat",
"email": "support@github.com",
"date": "2011-04-14T16:00:49Z"
},
"message": "Fix all the bugs",
"tree": {
"url": "https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
}
},
"author": {
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}, …Run Code Online (Sandbox Code Playgroud) 我努力寻找一个简单的代码行,它使用oauth令牌从企业github读取文件内容,但是找不到这样的例子.
我试过https://github.com/jcabi/jcabi-github,但它不支持企业github?(也许我错了)
现在我正在尝试自我:
GitHubClient client = new GitHubClient("enterprise url");
GitHubRequest request = new GitHubRequest();
request.setUri("/readme");
GitHubResponse response = client.get(request);
Run Code Online (Sandbox Code Playgroud)
那又怎样?我只看到了一个getBody,也许我需要用一些json库来解析它?它必须更简单..我期待的东西像:repo.get(url).getContent()
v3具有用于检索readme.md文件的特定API.但是在新的V4 GraphQL中,Repository Object中没有这样的字段.
有谁知道如何检索自述文件?
谢谢!
我正在尝试使用Probot Framework构建GitHub应用程序。
这是file的内容index.js:
module.exports = (robot) => {
robot.log('Yay, the app was loaded!');
robot.on('*', async context => {
robot.log('Some event occured!');
});
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行此应用程序时,将其安装在存储库中后,我收到此错误:
03:38:34.831Z ERROR probot: signature does not match event payload and secret
Error: signature does not match event payload and secret
at verifyAndReceive (/mnt/e/GSoC/test/test/node_modules/@octokit/webhooks/middleware/verify-and-receive.js:9:19)
at IncomingMessage.request.on (/mnt/e/GSoC/test/test/node_modules/@octokit/webhooks/middleware/middleware.js:53:5)
at emitNone (events.js:106:13)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
Run Code Online (Sandbox Code Playgroud)
这个错误背后的问题是什么?我该如何解决这个问题?