ocotkit无法获得组织私人回购提交

时间:2019-12-25 09:40:10

标签: node.js git github octokit

我正在使用带有节点的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,

1 个答案:

答案 0 :(得分:0)

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

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