例如,我在当前存储库中有五个分支,它们的名称是:master,branch1,branch2,branch3和branch4。使用打字稿语言进行probot构建可获取这些名称。
我尝试过的事情:
import { Application } from 'probot'
export = (app: Application) => {
app.on(`*`, async context => {
var branchName = context.github.repos.listBranches.name
var branchName1 = context.github.repos.getBranch.name
var branchName2 = context.payload.Status.branches.name
console.log(branchName + "\n")
// result: bound apiMethod
console.log(branchName1 + "\n")
// result: bound apiMethod
console.log(branchName2 + "\n")
// result: ERROR event: Cannot read property 'branches' of undefined
})
}
请在这里也说明bound apiMethod
的含义。
谢谢!
答案 0 :(得分:0)
const myRepoID = context.repo({number: context.payload.repository.id})
await context.github.repos.listBranches(myRepoID)