【问题标题】:How to get names of all branches in repository?如何获取存储库中所有分支的名称?
【发布时间】:2019-08-05 17:43:16
【问题描述】:

比如我在当前仓库中有五个分支,它们的名字分别是:master、branch1、branch2、branch3、branch4。使用用于 probot 构建的 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在这里的含义。

谢谢!

【问题讨论】:

    标签: git typescript github probot


    【解决方案1】:
    const myRepoID = context.repo({number: context.payload.repository.id})
    await context.github.repos.listBranches(myRepoID)
    

    【讨论】:

      猜你喜欢
      • 2014-09-15
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 2015-03-10
      • 2020-03-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多