Skip to content

Commit 4d353de

Browse files
authored
Update octokit (#6695)
* Update octokit * Fix tests * Switch back to a version of octokit that supports commonjs
1 parent 05c1d44 commit 4d353de

File tree

11 files changed

+132
-131
lines changed

11 files changed

+132
-131
lines changed

.eslintrc.base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"import/no-default-export": "off", // TODO@eamodio revisit
103103
"import/no-duplicates": "error",
104104
"import/no-self-import": "error",
105-
"import/no-unresolved": ["warn", { "ignore": ["vscode", "ghpr", "git", "extensionApi"] }],
105+
"import/no-unresolved": ["warn", { "ignore": ["vscode", "ghpr", "git", "extensionApi", "@octokit/rest", "@octokit/types"] }],
106106
"import/order": [
107107
"warn",
108108
{

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,8 +3812,8 @@
38123812
"webpack-cli": "4.2.0"
38133813
},
38143814
"dependencies": {
3815-
"@octokit/rest": "18.2.1",
3816-
"@octokit/types": "6.10.1",
3815+
"@octokit/rest": "20.1.2",
3816+
"@octokit/types": "13.8.0",
38173817
"@vscode/extension-telemetry": "0.7.5",
38183818
"@vscode/prompt-tsx": "^0.3.0-alpha.12",
38193819
"apollo-boost": "^0.4.9",

src/github/common.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,30 @@ export namespace OctokitCommon {
1111
export type IssuesCreateResponseData = OctokitRest.RestEndpointMethodTypes['issues']['create']['response']['data'];
1212
export type IssuesListCommentsResponseData = OctokitRest.RestEndpointMethodTypes['issues']['listComments']['response']['data'];
1313
export type IssuesListEventsForTimelineResponseData = Endpoints['GET /repos/{owner}/{repo}/issues/{issue_number}/timeline']['response']['data'];
14-
export type IssuesListEventsForTimelineResponseItemActor = IssuesListEventsForTimelineResponseData[0]['actor'];
14+
export type IssuesListEventsForTimelineResponseItemActor = {
15+
name?: string | null;
16+
email?: string | null;
17+
login: string;
18+
id: number;
19+
node_id: string;
20+
avatar_url: string;
21+
gravatar_id: string;
22+
url: string;
23+
html_url: string;
24+
followers_url: string;
25+
following_url: string;
26+
gists_url: string;
27+
starred_url: string;
28+
subscriptions_url: string;
29+
organizations_url: string;
30+
repos_url: string;
31+
events_url: string;
32+
received_events_url: string;
33+
type: string;
34+
site_admin: boolean;
35+
starred_at: string;
36+
user_view_type: string;
37+
}
1538
export type PullsCreateParams = OctokitRest.RestEndpointMethodTypes['pulls']['create']['parameters'];
1639
export type PullsCreateReviewResponseData = Endpoints['POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews']['response']['data'];
1740
export type PullsCreateReviewCommentResponseData = Endpoints['POST /repos/{owner}/{repo}/pulls/{pull_number}/comments']['response']['data'];
@@ -33,7 +56,6 @@ export namespace OctokitCommon {
3356
export type PullsListResponseItemHeadUser = PullsListResponseItemHead['user'];
3457
export type PullsListResponseItemHeadRepoOwner = PullsListResponseItemHead['repo']['owner'];
3558
export type PullsListReviewRequestsResponseTeamsItem = Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers']['response']['data']['teams'][0];
36-
export type PullsListResponseItemHeadRepoTemplateRepository = PullsListResponseItem['head']['repo']['template_repository'];
3759
export type PullsListCommitsResponseItem = Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}/commits']['response']['data'][0];
3860
export type ReposCompareCommitsResponseData = OctokitRest.RestEndpointMethodTypes['repos']['compareCommits']['response']['data'];
3961
export type ReposGetCombinedStatusForRefResponseStatusesItem = Endpoints['GET /repos/{owner}/{repo}/commits/{ref}/status']['response']['data']['statuses'][0];
@@ -46,7 +68,7 @@ export namespace OctokitCommon {
4668
export type SearchReposResponseItem = Endpoints['GET /search/repositories']['response']['data']['items'][0];
4769
export type CompareCommits = Endpoints['GET /repos/{owner}/{repo}/compare/{base}...{head}']['response']['data'];
4870
export type Commit = CompareCommits['commits'][0];
49-
export type CommitFile = CompareCommits['files'][0];
71+
export type CommitFiles = CompareCommits['files']
5072
export type Notification = Endpoints['GET /notifications']['response']['data'][0];
5173
}
5274

src/github/createPRViewProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -978,11 +978,11 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
978978

979979
private async getCommitsAndPatches(): Promise<{ commitMessages: string[], patches: { patch: string, fileUri: string, previousFileUri?: string }[] }> {
980980
let commitMessages: string[];
981-
let patches: ({ patch: string, fileUri: string, previousFileUri?: string } | undefined)[];
981+
let patches: ({ patch: string, fileUri: string, previousFileUri?: string } | undefined)[] | undefined;
982982
if (await this.model.getCompareHasUpstream()) {
983983
[commitMessages, patches] = await Promise.all([
984984
this.model.gitHubCommits().then(rawCommits => rawCommits.map(commit => commit.commit.message)),
985-
this.model.gitHubFiles().then(rawPatches => rawPatches.map(file => {
985+
this.model.gitHubFiles().then(rawPatches => rawPatches?.map(file => {
986986
if (!file.patch) {
987987
return;
988988
}
@@ -1001,7 +1001,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
10011001
}))]);
10021002
}
10031003
const filteredPatches: { patch: string, fileUri: string, previousFileUri?: string }[] =
1004-
patches.filter<{ patch: string, fileUri: string, previousFileUri?: string }>((patch): patch is { patch: string, fileUri: string, previousFileUri?: string } => !!patch);
1004+
patches?.filter<{ patch: string, fileUri: string, previousFileUri?: string }>((patch): patch is { patch: string, fileUri: string, previousFileUri?: string } => !!patch) ?? [];
10051005
return { commitMessages, patches: filteredPatches };
10061006
}
10071007

src/github/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export function convertRESTHeadToIGitHubRef(head: OctokitCommon.PullsListRespons
284284
sha: head.sha,
285285
repo: {
286286
cloneUrl: head.repo.clone_url,
287-
isInOrganization: !!head.repo.organization,
287+
isInOrganization: head.repo.owner.type === 'Organization',
288288
owner: head.repo.owner!.login,
289289
name: head.repo.name
290290
},
@@ -1304,7 +1304,7 @@ export function parseNotification(notification: OctokitCommon.Notification): Not
13041304
type: notification.subject.type as NotificationSubjectType,
13051305
url: notification.subject.url
13061306
},
1307-
lastReadAt: new Date(notification.last_read_at),
1307+
lastReadAt: notification.last_read_at ? new Date(notification.last_read_at) : undefined,
13081308
reason: notification.reason,
13091309
unread: notification.unread,
13101310
updatedAd: new Date(notification.updated_at),

src/test/builders/rest/repoBuilder.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
16
import { UserBuilder } from './userBuilder';
27
import { OrganizationBuilder } from './organizationBuilder';
38
import { createBuilderClass, createLink } from '../base';
49
import { OctokitCommon } from '../../../github/common';
5-
import { ForkDetails } from '../../../github/githubRepository';
610

711
export type RepoUnion = OctokitCommon.ReposGetResponseData &
812
OctokitCommon.PullsListResponseItemHeadRepo &
@@ -91,6 +95,7 @@ export const RepositoryBuilder = createBuilderClass<RepoUnion>()({
9195
has_wiki: { default: true },
9296
has_pages: { default: false },
9397
has_downloads: { default: true },
98+
has_discussions: { default: false },
9499
archived: { default: false },
95100
pushed_at: { default: '2011-01-26T19:06:43Z' },
96101
created_at: { default: '2011-01-26T19:01:12Z' },

src/test/builders/rest/teamBuilder.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
16
import { createBuilderClass } from '../base';
27
import { OctokitCommon } from '../../../github/common';
38

@@ -15,7 +20,7 @@ export const TeamBuilder = createBuilderClass<TeamUnion>()({
1520
members_url: { default: 'https://api.github.com/teams/1/members{/member}' },
1621
repositories_url: { default: 'https://api.github.com/teams/1/repos' },
1722
html_url: { default: 'https://api.github.com/teams/1' },
18-
ldap_dn: { default: '' },
23+
parent: { default: null }
1924
});
2025

2126
export type TeamBuilder = InstanceType<typeof TeamBuilder>;

src/test/builders/rest/userBuilder.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
16
import { createBuilderClass } from '../base';
27
import { OctokitCommon } from '../../../github/common';
38

@@ -32,6 +37,9 @@ export const UserBuilder = createBuilderClass<Required<UserUnion>>()({
3237
type: { default: 'User' },
3338
site_admin: { default: false },
3439
starred_at: { default: '' },
40+
email: { default: 'email' },
41+
name: { default: 'Name' },
42+
user_view_type: { default: 'User' }
3543
});
3644

3745
export type UserBuilder = InstanceType<typeof UserBuilder>;

src/view/createPullRequestDataModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class CreatePullRequestDataModel extends Disposable {
3636

3737
private _gitHubMergeBase: string | undefined;
3838
private _gitHubLog: OctokitCommon.Commit[] | undefined;
39-
private _gitHubFiles: OctokitCommon.CommitFile[] | undefined;
39+
private _gitHubFiles: OctokitCommon.CommitFiles;
4040

4141
private _gitHubcontentProvider: GitHubContentProvider;
4242
private _gitcontentProvider: GitContentProvider;
@@ -232,7 +232,7 @@ export class CreatePullRequestDataModel extends Disposable {
232232
return this._gitHubLog;
233233
}
234234

235-
public async gitHubFiles(): Promise<OctokitCommon.CommitFile[]> {
235+
public async gitHubFiles(): Promise<OctokitCommon.CommitFiles> {
236236
await this._constructed;
237237
if (this._gitHubFiles === undefined) {
238238
await this.gitHubCommits();

webpack.config.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,6 @@ async function getExtensionConfig(target, mode, env) {
296296
alias:
297297
target === 'webworker'
298298
? {
299-
'universal-user-agent': path.join(
300-
__dirname,
301-
'node_modules',
302-
'universal-user-agent',
303-
'dist-web',
304-
'index.js',
305-
),
306299
'node-fetch': 'cross-fetch',
307300
'../env/node/net': path.resolve(__dirname, 'src', 'env', 'browser', 'net'),
308301
'../env/node/ssh': path.resolve(__dirname, 'src', 'env', 'browser', 'ssh'),

0 commit comments

Comments
 (0)