如何获取存储库中所有分支的名称?
How to get names of all branches in repository?
比如我在当前版本库中有五个分支,它们的名字分别是:master、branch1、branch2、branch3、branch4。使用 probot build 的 typescript 语言来获取这些名称。
我尝试过的:
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
是什么意思。
谢谢!
const myRepoID = context.repo({number: context.payload.repository.id})
await context.github.repos.listBranches(myRepoID)
比如我在当前版本库中有五个分支,它们的名字分别是:master、branch1、branch2、branch3、branch4。使用 probot build 的 typescript 语言来获取这些名称。
我尝试过的:
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
是什么意思。
谢谢!
const myRepoID = context.repo({number: context.payload.repository.id})
await context.github.repos.listBranches(myRepoID)