Skip to content

fix: use octokit.rest interface for github #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31165,7 +31165,7 @@ const getOpenPRs = async () => {
};
}

const { data } = await octokit.pulls.list({
const { data } = await octokit.rest.pulls.list({
...repo,
base: baseBranch,
state: 'open',
Expand All @@ -31179,7 +31179,7 @@ const getOpenPRs = async () => {
const updatePRBranch = async (pullNumber) => {
const octokit = getOctokit();
const repo = github.context.repo;
const { data } = await octokit.pulls.updateBranch({
const { data } = await octokit.rest.pulls.updateBranch({
...repo,
pull_number: pullNumber,
});
Expand All @@ -31193,7 +31193,7 @@ const updatePRBranch = async (pullNumber) => {
const getPR = async (pullNumber) => {
const octokit = getOctokit();
const repo = github.context.repo;
const result = await octokit.pulls.get({
const result = await octokit.rest.pulls.get({
...repo,
pull_number: pullNumber,
});
Expand Down Expand Up @@ -31242,7 +31242,7 @@ const areAllChecksPassed = async (sha) => {
const repo = github.context.repo;
const {
data: { check_runs },
} = await octokit.checks.listForRef({
} = await octokit.rest.checks.listForRef({
...repo,
ref: sha,
});
Expand All @@ -31262,7 +31262,7 @@ const getApprovalStatus = async (pullNumber) => {
const repo = github.context.repo;
const requiredApprovalCount = github_core.getInput('required_approval_count');

const { data: reviewsData } = await octokit.pulls.listReviews({
const { data: reviewsData } = await octokit.rest.pulls.listReviews({
...repo,
pull_number: pullNumber,
});
Expand Down
10 changes: 5 additions & 5 deletions src/lib/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getOpenPRs = async () => {
};
}

const { data } = await octokit.pulls.list({
const { data } = await octokit.rest.pulls.list({
...repo,
base: baseBranch,
state: 'open',
Expand All @@ -42,7 +42,7 @@ export const getOpenPRs = async () => {
export const updatePRBranch = async (pullNumber) => {
const octokit = getOctokit();
const repo = github.context.repo;
const { data } = await octokit.pulls.updateBranch({
const { data } = await octokit.rest.pulls.updateBranch({
...repo,
pull_number: pullNumber,
});
Expand All @@ -56,7 +56,7 @@ export const updatePRBranch = async (pullNumber) => {
export const getPR = async (pullNumber) => {
const octokit = getOctokit();
const repo = github.context.repo;
const result = await octokit.pulls.get({
const result = await octokit.rest.pulls.get({
...repo,
pull_number: pullNumber,
});
Expand Down Expand Up @@ -105,7 +105,7 @@ export const areAllChecksPassed = async (sha) => {
const repo = github.context.repo;
const {
data: { check_runs },
} = await octokit.checks.listForRef({
} = await octokit.rest.checks.listForRef({
...repo,
ref: sha,
});
Expand All @@ -125,7 +125,7 @@ export const getApprovalStatus = async (pullNumber) => {
const repo = github.context.repo;
const requiredApprovalCount = core.getInput('required_approval_count');

const { data: reviewsData } = await octokit.pulls.listReviews({
const { data: reviewsData } = await octokit.rest.pulls.listReviews({
...repo,
pull_number: pullNumber,
});
Expand Down
56 changes: 32 additions & 24 deletions src/lib/github.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('updatePRBranch()', () => {

beforeEach(() => {
github.getOctokit.mockReturnValue({
pulls: { updateBranch: mockedUpdateBranch },
rest: { pulls: { updateBranch: mockedUpdateBranch } },
});
});
afterEach(() => {
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('getPR()', () => {
test('should send the expected parameters', async () => {
const mockedMethod = jest.fn().mockResolvedValue(mockedResponse);
github.getOctokit.mockReturnValue({
pulls: { get: mockedMethod },
rest: { pulls: { get: mockedMethod } },
});
const res = await gitLib.getPR(pullNumber);

Expand All @@ -110,7 +110,7 @@ describe('getOpenPRs()', () => {
test('should send the expected parameters', async () => {
const mockedMethod = jest.fn().mockResolvedValue(mockedResponse);
github.getOctokit.mockReturnValue({
pulls: { list: mockedMethod },
rest: { pulls: { list: mockedMethod } },
});
const res = await gitLib.getOpenPRs(pullNumber);

Expand All @@ -134,7 +134,7 @@ describe('getOpenPRs()', () => {

const mockedMethod = jest.fn().mockResolvedValue(mockedResponse);
github.getOctokit.mockReturnValue({
pulls: { list: mockedMethod },
rest: { pulls: { list: mockedMethod } },
});
await gitLib.getOpenPRs(pullNumber);

Expand All @@ -155,7 +155,7 @@ describe('getOpenPRs()', () => {

const mockedMethod = jest.fn().mockResolvedValue(mockedResponse);
github.getOctokit.mockReturnValue({
pulls: { list: mockedMethod },
rest: { pulls: { list: mockedMethod } },
});
await gitLib.getOpenPRs(pullNumber);

Expand Down Expand Up @@ -183,7 +183,7 @@ describe('getMergeableStatus()', () => {
};
const mockedMethod = jest.fn().mockResolvedValue(mockedResponse);
github.getOctokit.mockReturnValue({
pulls: { get: mockedMethod },
rest: { pulls: { get: mockedMethod } },
});
const status = await gitLib.getMergeableStatus();
expect(status).toEqual(mergeableStatus);
Expand All @@ -203,7 +203,7 @@ describe('getMergeableStatus()', () => {
.mockResolvedValueOnce(mockedResponseFinal);

github.getOctokit.mockReturnValue({
pulls: { get: mockedMethod },
rest: { pulls: { get: mockedMethod } },
});
jest.spyOn(utils, 'wait').mockImplementation();

Expand All @@ -230,7 +230,7 @@ describe('areAllChecksPassed()', () => {
const mockedMethod = jest.fn().mockResolvedValue(mockedResponse);

github.getOctokit.mockReturnValue({
checks: { listForRef: mockedMethod },
rest: { checks: { listForRef: mockedMethod } },
});

const result = await gitLib.areAllChecksPassed(sha);
Expand All @@ -246,7 +246,7 @@ describe('areAllChecksPassed()', () => {
const mockedMethod = jest.fn().mockResolvedValue(mockedResponse);

github.getOctokit.mockReturnValue({
checks: { listForRef: mockedMethod },
rest: { checks: { listForRef: mockedMethod } },
});

const result = await gitLib.areAllChecksPassed(sha);
Expand All @@ -265,7 +265,7 @@ describe('areAllChecksPassed()', () => {
const mockedMethod = jest.fn().mockResolvedValue(mockedResponse);

github.getOctokit.mockReturnValue({
checks: { listForRef: mockedMethod },
rest: { checks: { listForRef: mockedMethod } },
});

const result = await gitLib.areAllChecksPassed(sha);
Expand All @@ -284,7 +284,7 @@ describe('getApprovalStatus()', () => {
const mockedMethod = jest.fn().mockResolvedValue(reviewsList);

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedMethod },
rest: { pulls: { listReviews: mockedMethod } },
});

const result = await gitLib.getApprovalStatus(pullNumber);
Expand All @@ -311,7 +311,7 @@ describe('getApprovalStatus()', () => {
const mockedMethod = jest.fn().mockResolvedValue(reviews);

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedMethod },
rest: { pulls: { listReviews: mockedMethod } },
});

const result = await gitLib.getApprovalStatus(pullNumber);
Expand Down Expand Up @@ -379,7 +379,7 @@ describe('getAutoUpdateCandidate()', () => {
const mockedGet = jest.fn();

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedListReviews, get: mockedGet },
rest: { pulls: { listReviews: mockedListReviews, get: mockedGet } },
});

const res = await gitLib.getAutoUpdateCandidate(prList);
Expand All @@ -405,7 +405,7 @@ describe('getAutoUpdateCandidate()', () => {
const mockedGet = jest.fn();

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedListReviews, get: mockedGet },
rest: { pulls: { listReviews: mockedListReviews, get: mockedGet } },
});

const res = await gitLib.getAutoUpdateCandidate(prList);
Expand Down Expand Up @@ -442,7 +442,7 @@ describe('getAutoUpdateCandidate()', () => {
const mockedGet = jest.fn().mockResolvedValue(prData);

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedListReviews, get: mockedGet },
rest: { pulls: { listReviews: mockedListReviews, get: mockedGet } },
});

const res = await gitLib.getAutoUpdateCandidate(prList);
Expand Down Expand Up @@ -476,7 +476,7 @@ describe('getAutoUpdateCandidate()', () => {
const mockedGet = jest.fn().mockResolvedValue(prData);

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedListReviews, get: mockedGet },
rest: { pulls: { listReviews: mockedListReviews, get: mockedGet } },
});

const res = await gitLib.getAutoUpdateCandidate(prList);
Expand Down Expand Up @@ -523,8 +523,10 @@ describe('getAutoUpdateCandidate()', () => {
const mockedListForRef = jest.fn().mockResolvedValue(checks);

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedListReviews, get: mockedGet },
checks: { listForRef: mockedListForRef },
rest: {
pulls: { listReviews: mockedListReviews, get: mockedGet },
checks: { listForRef: mockedListForRef },
},
});

const res = await gitLib.getAutoUpdateCandidate(prList);
Expand Down Expand Up @@ -572,8 +574,10 @@ describe('getAutoUpdateCandidate()', () => {
const mockedListForRef = jest.fn().mockResolvedValue(checks);

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedListReviews, get: mockedGet },
checks: { listForRef: mockedListForRef },
rest: {
pulls: { listReviews: mockedListReviews, get: mockedGet },
checks: { listForRef: mockedListForRef },
},
});

const res = await gitLib.getAutoUpdateCandidate(prList);
Expand Down Expand Up @@ -616,8 +620,10 @@ describe('getAutoUpdateCandidate()', () => {
const mockedListForRef = jest.fn().mockResolvedValue(checks);

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedListReviews, get: mockedGet },
checks: { listForRef: mockedListForRef },
rest: {
pulls: { listReviews: mockedListReviews, get: mockedGet },
checks: { listForRef: mockedListForRef },
},
});

const res = await gitLib.getAutoUpdateCandidate(prList);
Expand Down Expand Up @@ -680,8 +686,10 @@ describe('getAutoUpdateCandidate()', () => {
const mockedListForRef = jest.fn().mockResolvedValue(checks);

github.getOctokit.mockReturnValue({
pulls: { listReviews: mockedListReviews, get: mockedGet },
checks: { listForRef: mockedListForRef },
rest: {
pulls: { listReviews: mockedListReviews, get: mockedGet },
checks: { listForRef: mockedListForRef },
},
});

const res = await gitLib.getAutoUpdateCandidate(prList);
Expand Down