Skip to content
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

fix(deps): update to the latest version of octokit #181

Merged
merged 1 commit into from
Mar 23, 2021
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
138 changes: 14 additions & 124 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"pretest": "npm run compile"
},
"dependencies": {
"@octokit/rest": "^18.0.1",
"@octokit/rest": "^18.3.5",
"@types/yargs": "^16.0.0",
"async-retry": "^1.3.1",
"diff": "^5.0.0",
Expand All @@ -53,6 +53,7 @@
"devDependencies": {
"@microsoft/api-documenter": "^7.8.10",
"@microsoft/api-extractor": "^7.8.10",
"@octokit/types": "^6.12.2",
"@types/async-retry": "^1.4.2",
"@types/chai": "^4.2.11",
"@types/diff": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/github-handler/fork-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function fork(
).data;
const origin: RepoDomain = {
repo: forkedRepo.name,
owner: forkedRepo.owner.login,
owner: forkedRepo.owner!.login,
};
logger.info(
`Create fork request was successful for ${origin.owner}/${origin.repo}`
Expand Down
33 changes: 23 additions & 10 deletions test/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,25 @@ import {describe, it, before, afterEach} from 'mocha';
import {assert, expect} from 'chai';
import {octokit, setup} from './util';
import * as sinon from 'sinon';
import {GetResponseTypeFromEndpointMethod} from '@octokit/types';
import {
branch,
getBranchHead,
createRef,
} from '../src/github-handler/branch-handler';

type GetBranchResponse = GetResponseTypeFromEndpointMethod<
typeof octokit.repos.getBranch
>;

type GetRefResponse = GetResponseTypeFromEndpointMethod<
typeof octokit.git.getRef
>;

type CreateRefResponse = GetResponseTypeFromEndpointMethod<
typeof octokit.git.createRef
>;

before(() => {
setup();
});
Expand All @@ -45,7 +58,7 @@ describe('Branch', () => {
status: 200,
url: 'http://fake-url.com',
data: branchResponseBody,
};
} as GetBranchResponse;

const getBranchStub = sandbox
.stub(octokit.repos, 'getBranch')
Expand All @@ -70,8 +83,8 @@ describe('Branch', () => {
status: 200,
url: 'http://fake-url.com',
data: branchResponseBody,
};
const createRefResponse = {
} as GetBranchResponse;
const createRefResponse = ({
headers: {},
status: 200,
url: 'http://fake-url.com',
Expand All @@ -87,7 +100,7 @@ describe('Branch', () => {
'https://api.github.com/repos/fake-Owner/HelloWorld/git/commits/f826b1caabafdffec3dc45a08e41d7021c68db41',
},
},
};
} as unknown) as CreateRefResponse;
const getBranchStub = sandbox
.stub(octokit.repos, 'getBranch')
.resolves(branchResponse);
Expand Down Expand Up @@ -130,14 +143,14 @@ describe('Branch', () => {
status: 200,
url: 'http://fake-url.com',
data: branchResponseBody,
};
} as GetBranchResponse;
const getRefResponseBody = await import('./fixtures/get-ref-response.json');
const getRefResponse = {
const getRefResponse = ({
headers: {},
status: 404,
url: 'http://fake-url.com',
data: getRefResponseBody,
};
} as unknown) as GetRefResponse;
const getBranchStub = sandbox
.stub(octokit.repos, 'getBranch')
.resolves(branchResponse);
Expand Down Expand Up @@ -185,7 +198,7 @@ describe('Branch', () => {
status: 200,
url: 'http://fake-url.com',
data: branchResponseBody,
};
} as GetBranchResponse;
sandbox.stub(octokit.repos, 'getBranch').resolves(branchResponse);
sandbox.stub(octokit.git, 'getRef').rejects(Error(testErrorMessage));
try {
Expand All @@ -204,7 +217,7 @@ describe('Branch', () => {
status: 200,
url: 'http://fake-url.com',
data: branchResponseBody,
};
} as GetBranchResponse;
sandbox.stub(octokit.repos, 'getBranch').resolves(branchResponse);
const getRefError = Error('Not Found');
Object.assign(getRefError, {status: 404});
Expand All @@ -226,7 +239,7 @@ describe('Branch', () => {
status: 200,
url: 'http://fake-url.com',
data: branchResponseBody,
};
} as GetBranchResponse;
sandbox.stub(octokit.repos, 'getBranch').resolves(branchResponse);
try {
await branch(octokit, origin, upstream, branchName, 'non-master-branch');
Expand Down
29 changes: 21 additions & 8 deletions test/commit-and-push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@ import {expect} from 'chai';
import {describe, it, before, afterEach} from 'mocha';
import {octokit, setup} from './util';
import * as sinon from 'sinon';
import {GetResponseTypeFromEndpointMethod} from '@octokit/types';
import * as handler from '../src/github-handler/commit-and-push-handler';
import {Changes, FileData, TreeObject, RepoDomain} from '../src/types';

type GetCommitResponse = GetResponseTypeFromEndpointMethod<
typeof octokit.git.getCommit
>;

type CreateTreeResponse = GetResponseTypeFromEndpointMethod<
typeof octokit.git.createTree
>;

type CreateCommitResponse = GetResponseTypeFromEndpointMethod<
typeof octokit.git.createCommit
>;

before(() => {
setup();
});
Expand Down Expand Up @@ -121,13 +134,13 @@ describe('Push', () => {
status: 200,
url: 'http://fake-url.com',
data: commitResponseData,
};
} as GetCommitResponse;
const createTreeResponse = {
headers: {},
status: 200,
status: 201,
url: 'http://fake-url.com',
data: createTreeResponseData,
};
} as CreateTreeResponse;
// setup
const stubGetCommit = sandbox
.stub(octokit.git, 'getCommit')
Expand Down Expand Up @@ -174,7 +187,7 @@ describe('Commit', () => {
status: 201,
url: 'http://fake-url.com',
data: createCommitResponseData,
};
} as CreateCommitResponse;
const stubCreateCommit = sandbox
.stub(octokit.git, 'createCommit')
.resolves(createCommitResponse);
Expand Down Expand Up @@ -249,13 +262,13 @@ describe('Commit and push function', async () => {
status: 200,
url: 'http://fake-url.com',
data: commitResponseData,
};
} as GetCommitResponse;
const createTreeResponse = {
headers: {},
status: 200,
status: 201,
url: 'http://fake-url.com',
data: createTreeResponseData,
};
} as CreateTreeResponse;

const createCommitResponseData = await import(
'./fixtures/create-commit-response.json'
Expand All @@ -265,7 +278,7 @@ describe('Commit and push function', async () => {
status: 201,
url: 'http://fake-url.com',
data: createCommitResponseData,
};
} as CreateCommitResponse;
afterEach(() => {
sandbox.restore();
});
Expand Down
Loading