【问题标题】:ocotkit unable to get organisation private repo commitocotkit 无法获取组织私有 repo 提交
【发布时间】:2019-12-25 09:40:10
【问题描述】:

我正在使用带有节点的 octokit 并尝试获取单个提交详细信息

但得到 404

生成的个人访问令牌、所有者等

对于我的私人仓库它正在工作,但对于组织私人仓库不工作我刚刚获得了所有者对组织的访问权限并更新了令牌

const { IncomingWebhook } = require('@slack/client');
const humanizeDuration = require('humanize-duration');
const Octokit = require('@octokit/rest');


const GITHUB_ACCESS_TOKEN = 'XXXXXXXXXXXXXXXXXXXXX';

const token = GITHUB_ACCESS_TOKEN;
const octokit = require('@octokit/rest')({
  auth: `token ${token}`
})

module.exports.getGithubCommit = async (build, octokit) => {
    try {
        console.log("Inside Github function");
        const githubRepo   = 'XXXXXXXXXXXXXX';
        const githubBranch = 'XXXXXXXXXXXXX';
        const commitSha    = 'XXXXXXXXXXXXXXXX';
        const githubCommit = await octokit.git.getCommit({
            commit_sha: commitSha,
            owner: 'harshmanvar',
            repo: githubRepo,
        });
        console.log("Github commit value",githubCommit);
        return githubCommit;
    } catch (err) {
        console.log('error',err);
        return err;
    }
};

const githubCommit = module.exports.getGithubCommit(build, octokit);

如果我遗漏了什么,请告诉我,这是因为我刚刚获得了组织的访问权限,所以我无法访问旧的提交详细信息?

当我试图在我找到的所有存储库中列出组织的存储库时

owner : [object]

{ id: 12345674890,
       node_id: 'XXXXXXXXXXXXXXXXXXXX',
       name: 'XXXXX',
       full_name: 'XXXXXXXXXXXX',
       private: true,
       owner: [Object],
       html_url: 'https://github.com/org/XXXXXXXXXXXXX',
       description: null,
       fork: false,

【问题讨论】:

    标签: node.js git github octokit


    【解决方案1】:

    要从组织存储库中获取提交详细信息,我们必须将组织名称作为所有者传递。

    commit_sha: commitSha,
                owner: 'acme-org',
                repo: githubRepo,
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-03
      • 2019-06-28
      • 2019-10-27
      • 1970-01-01
      • 1970-01-01
      • 2014-01-26
      • 2012-03-13
      相关资源
      最近更新 更多