我有一个 GitHub 组织,我正在尝试确定组织中所有用户的上次登录日期。
我看到有一种方法可以获取最后一次提交,但是有些用户只进行拉取,所以这不起作用。
该/users/:user/events调用不会为我返回任何结果。
我想将存储库从 GitHub Enterprise 迁移到 GitHub。
有关如何反之亦然的文档非常丰富。
然而,“朝我的方向”移动似乎只包含在这个问题中。那里的答案只说了如何迁移提交/分支,这只是我需要的一部分。
有没有办法将整个存储库(至少包括所有问题)从 GitHub Enterprise (v2.8) 迁移到 GitHub?理想情况下,所有作者都应引用 GitHub 上的相应用户。
似乎有一个 API,适用于GitHub Enterprise和GitHub。似乎可以选择编写一个脚本,例如手动从 GitHub Enterprise 检索所有问题,然后将其放在 GitHub 上。如果是这种情况,是否有人知道已经执行此操作的脚本?
在向 GitHub API 发出一些 HTTP 请求后,它开始拒绝调用,并显示:
xxx.xxx.xxx.xxx 超出 API 速率限制。(但好消息是:经过身份验证的请求可以获得更高的速率限制。请查看文档以了解更多详细信息。)
现在,有一种方法可以提高 OAuth 应用程序的未经身份验证的速率限制,其中涉及使用client secret.
当然,我们不想将或放在client secret前端应用程序的公共源代码上,正如文档所建议的那样:
注意:切勿与任何人分享您的客户端密钥或将其包含在客户端浏览器代码中。仅将此处显示的方法用于服务器到服务器的调用。
所以我想知道解决前端应用程序中速率限制问题的最佳方法是什么。
我发现了很多线程——甚至有几个项目使用 github api 之外的 api 嵌入了贡献日历——但这些方法或线程都没有真正回答这个问题。有一件事很接近,但这是不可能的。
我只是想获取用户的贡献总数,如 github 个人资料页面上的日历所示,如下所示......
api 文档描述了收集 Repo Contrib 数据,因此我尝试用有根据的猜测盲目地尝试 api,但没有成功。有谁知道这个数据实际上是否有一个可行的端点?我真的需要自己计算这些信息还是做一些肮脏的 html 抓取废话?这看起来很愚蠢...有人吗?
更新:对于任何寻求快速网络抓取解决方案的人来说,这是一个使用cheerio和正则表达式的解决方案
const axios = require('axios')
const cheerio = require('cheerio')
const url = 'https://github.com/archae0pteryx'
function getCommits(url) {
return new Promise((resolve, reject) => {
axios.get(url).then(res => {
const load = cheerio.load(res.data)
const parsed = load('div.js-contribution-graph > h2').text()
const reg = /\d+/g
const x = parsed.match(reg)
resolve(x)
}).catch(err => reject(err))
})
}
getCommits(url)
.then(x => console.log(x))
.catch(err => console.error(err))
Run Code Online (Sandbox Code Playgroud) 我正在使用 github API 来遍历存储库并获取其中所有文件的列表。这种结构称为“树”。树基本上是一个子目录。因此,如果我想查看树的内容,我需要向该树的 ID 发出 GET 请求。响应将是表示该树中的项目的对象数组。但其中一些项目也将是树,因此我必须向该树发出另一个获取请求。存储库可能如下所示:
|src
app.jsx
container.jsx
|client
index.html
readme.md
Run Code Online (Sandbox Code Playgroud)
该结构将由以下对象表示
[
{ name:'src', type:'tree', id:43433432 },
{ name:'readme.md', type:'md', id:45489898 }
]
//a GET req to the id of the first object would return the following array:
[
{ name:'app.jsx', type:'file', id:57473738 },
{ name:'contain.jsx', type:'file', id:748433454 },
{ name:'client', type:'tree', id:87654433 }
]
//a GET req to the id of the third object would return the following array:
[
{ name:'index.html', type:'file', id:44444422 } …Run Code Online (Sandbox Code Playgroud) 当我尝试使用Github.js从大于 ~1MB 的文件中 getSha(以及随后的 getBlob)时,出现 403 错误。文件大小有限制吗?代码如下:
var gh = new GitHub({
username: username,
password: password
});
// get the repo from github
var repo = gh.getRepo('some-username','name-of-repo');
// get promise
repo.getSha('some-branch', 'some-file.json').then(function(result){
// pass the sha onto getBlob
return repo.getBlob(result.data.sha);
}).then(function(result){
do_something_with_blob(result.data);
});
Run Code Online (Sandbox Code Playgroud)
GitHub API 表示它支持最大 100MB 的 blob,但我在Github.js 文档中找不到任何有关文件大小限制的信息。此外,这些文件来自私人 Github 存储库。
我可以像这样查询第一个拉取请求:
query {
repository(owner: "test_owner", name: "test_name") {
pullRequests(first: 1) {
nodes {
id
number
title
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是我如何根据它查询某个拉取请求呢number?
以下不起作用:
query {
repository(owner: "test_owner", name: "test_name") {
pullRequests(first: 1, number: 50) { <-- CANNOT FILTER BY `number`
nodes {
id
number
title
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
给定问题或拉取请求编号,我希望使用对GitHub GraphQL API 的单个查询来获取以下信息:
使用以下查询,除了确定谁关闭了问题或 PR 之外,我可以完成所有这些工作:
{
repository(owner: "Automattic", name: "wp-calypso") {
issueOrPullRequest(number: 23226) {
__typename
... on Closable {
closed
closedAt
# TODO: How to get ClosedEvent { actor } ?
}
... on Issue {
issueState: state
title
}
... on PullRequest {
prState: state
title
merged
mergedAt
mergeCommit {
committer {
user {
login
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 GitHub …
v3 API 允许创建文件,但我似乎找不到使用 v4 GraphQL API 执行此操作的方法。目前可以吗?
使用 Github API(无本地 git 命令),是否可以比较分支以查看它在默认分支之前是否有任何更改?
我正在构建一个审核工具,并希望确定要关闭的候选分支,因为它们的所有更改都存在于默认分支中。
我想要驱动分支页面上的图表的相同信息:
(参见https://github.com/octokit/octokit.rb/branches)
是否可以纯粹通过 Github API 获取这些信息?