Skip to content

Commit 53e3898

Browse files
committed
Revert "Include branch protection on overview (#3411)"
This reverts commit bb9520b. Work around for #3430 until a real fix is made after the 0.40.0 release.
1 parent 8cc2117 commit 53e3898

File tree

10 files changed

+19
-73
lines changed

10 files changed

+19
-73
lines changed

src/github/credentials.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export class CredentialStore implements vscode.Disposable {
284284
request: { agent, fetch: fetchCore },
285285
userAgent: 'GitHub VSCode Pull Requests',
286286
// `shadow-cat-preview` is required for Draft PR API access -- https://developer.github.com/v3/previews/#draft-pull-requests
287-
previews: ['shadow-cat-preview', 'merge-info-preview'],
287+
previews: ['shadow-cat-preview'],
288288
auth: `${token || ''}`,
289289
baseUrl: baseUrl,
290290
});
@@ -321,7 +321,7 @@ const link = (url: string, token: string) =>
321321
headers: {
322322
...headers,
323323
authorization: token ? `Bearer ${token}` : '',
324-
Accept: 'application/vnd.github.shadow-cat-preview+json, application/vnd.github.antiope-preview+json, application/vnd.github.merge-info-preview+json',
324+
Accept: 'application/vnd.github.shadow-cat-preview+json, application/vnd.github.antiope-preview+json',
325325
},
326326
})).concat(
327327
createHttpLink({

src/github/githubRepository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ export class GitHubRepository implements vscode.Disposable {
701701
},
702702
});
703703
Logger.debug(`Fetch pull request ${id} - done`, GitHubRepository.ID);
704+
704705
return this.createOrUpdatePullRequestModel(parseGraphQLPullRequest(data, this));
705706
} catch (e) {
706707
Logger.appendLine(`GithubRepository> Unable to fetch PR: ${e}`);
@@ -723,7 +724,7 @@ export class GitHubRepository implements vscode.Disposable {
723724
});
724725
Logger.debug(`Fetch issue ${id} - done`, GitHubRepository.ID);
725726

726-
return new IssueModel(this, remote, parseGraphQLIssue(data.repository.pullRequest, this));
727+
return new IssueModel(this, remote, parseGraphQLPullRequest(data, this));
727728
} catch (e) {
728729
Logger.appendLine(`GithubRepository> Unable to fetch PR: ${e}`);
729730
return;

src/github/graphql.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ export interface PullRequest {
417417
};
418418
merged: boolean;
419419
mergeable: 'MERGEABLE' | 'CONFLICTING' | 'UNKNOWN';
420-
mergeStateStatus: 'BEHIND' | 'BLOCKED' | 'CLEAN' | 'DIRTY' | 'HAS_HOOKS' | 'UNKNOWN' | 'UNSTABLE';
421420
isDraft?: boolean;
422421
suggestedReviewers: SuggestedReviewerResponse[];
423422
milestone?: {
@@ -442,16 +441,6 @@ export interface PullRequestResponse {
442441
rateLimit: RateLimit;
443442
}
444443

445-
export interface PullRequestMergabilityResponse {
446-
repository: {
447-
pullRequest: {
448-
mergeable: 'MERGEABLE' | 'CONFLICTING' | 'UNKNOWN';
449-
mergeStateStatus: 'BEHIND' | 'BLOCKED' | 'CLEAN' | 'DIRTY' | 'HAS_HOOKS' | 'UNKNOWN' | 'UNSTABLE';
450-
};
451-
};
452-
rateLimit: RateLimit;
453-
}
454-
455444
export interface IssuesSearchResponse {
456445
search: {
457446
issueCount: number;

src/github/interface.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export enum GithubItemStateEnum {
2424
export enum PullRequestMergeability {
2525
Mergeable,
2626
NotMergeable,
27-
Conflict,
2827
Unknown,
2928
}
3029

src/github/pullRequestModel.ts

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
PendingReviewIdResponse,
3535
PullRequestCommentsResponse,
3636
PullRequestFilesResponse,
37-
PullRequestMergabilityResponse,
37+
PullRequestResponse,
3838
ReactionGroup,
3939
ResolveReviewThreadResponse,
4040
StartReviewResponse,
@@ -959,7 +959,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
959959
* Get the status checks of the pull request, those for the last commit.
960960
*/
961961
async getStatusChecks(): Promise<PullRequestChecks> {
962-
const { query, remote, schema, octokit } = await this.githubRepository.ensure();
962+
const { query, remote, schema } = await this.githubRepository.ensure();
963963
let result;
964964
try {
965965
result = await query<GetChecksResponse>({
@@ -991,7 +991,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
991991
};
992992
}
993993

994-
const checks: PullRequestChecks = {
994+
return {
995995
state: statusCheckRollup.state.toLowerCase(),
996996
statuses: statusCheckRollup.contexts.nodes.map(context => {
997997
if (isCheckRun(context)) {
@@ -1017,25 +1017,6 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
10171017
}
10181018
}),
10191019
};
1020-
1021-
// Fun info: The checks don't include whether a review is required.
1022-
// Also, unless you're an admin on the repo, you can't just do octokit.repos.getBranchProtection
1023-
if (this.item.mergeable === PullRequestMergeability.NotMergeable) {
1024-
const branch = await octokit.repos.getBranch({ branch: this.base.ref, owner: remote.owner, repo: remote.repositoryName });
1025-
if (branch.data.protected && branch.data.protection.required_status_checks.enforcement_level !== 'off') {
1026-
// We need to add the "review required" check manually.
1027-
checks.statuses.unshift({
1028-
id: 'unknown',
1029-
context: 'Branch Protection',
1030-
description: 'Requirements have not been met.',
1031-
state: 'failure',
1032-
target_url: this.html_url
1033-
});
1034-
checks.state = 'failure';
1035-
}
1036-
}
1037-
1038-
return checks;
10391020
}
10401021

10411022
static async openDiffFromComment(
@@ -1205,7 +1186,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
12051186
Logger.debug(`Fetch pull request mergeability ${this.number} - enter`, PullRequestModel.ID);
12061187
const { query, remote, schema } = await this.githubRepository.ensure();
12071188

1208-
const { data } = await query<PullRequestMergabilityResponse>({
1189+
const { data } = await query<PullRequestResponse>({
12091190
query: schema.PullRequestMergeability,
12101191
variables: {
12111192
owner: remote.owner,
@@ -1214,7 +1195,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
12141195
},
12151196
});
12161197
Logger.debug(`Fetch pull request mergeability ${this.number} - done`, PullRequestModel.ID);
1217-
return parseMergeability(data.repository.pullRequest.mergeable, data.repository.pullRequest.mergeStateStatus);
1198+
return parseMergeability(data.repository.pullRequest.mergeable);
12181199
} catch (e) {
12191200
Logger.appendLine(`PullRequestModel> Unable to fetch PR Mergeability: ${e}`);
12201201
return PullRequestMergeability.Unknown;

src/github/queries.gql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ query PullRequest($owner: String!, $name: String!, $number: Int!) {
334334
}
335335
merged
336336
mergeable
337-
mergeStateStatus
338337
id
339338
databaseId
340339
isDraft
@@ -503,7 +502,6 @@ query PullRequestMergeability($owner: String!, $name: String!, $number: Int!) {
503502
repository(owner: $owner, name: $name) {
504503
pullRequest(number: $number) {
505504
mergeable
506-
mergeStateStatus
507505
}
508506
}
509507
rateLimit {

src/github/utils.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -479,24 +479,15 @@ export function parseMilestone(
479479
};
480480
}
481481

482-
export function parseMergeability(mergeability: 'UNKNOWN' | 'MERGEABLE' | 'CONFLICTING',
483-
mergeStateStatus: 'BEHIND' | 'BLOCKED' | 'CLEAN' | 'DIRTY' | 'HAS_HOOKS' | 'UNKNOWN' | 'UNSTABLE'): PullRequestMergeability {
484-
let parsed: PullRequestMergeability;
482+
export function parseMergeability(mergeability: 'UNKNOWN' | 'MERGEABLE' | 'CONFLICTING'): PullRequestMergeability {
485483
switch (mergeability) {
486484
case 'UNKNOWN':
487-
parsed = PullRequestMergeability.Unknown;
488-
break;
485+
return PullRequestMergeability.Unknown;
489486
case 'MERGEABLE':
490-
parsed = PullRequestMergeability.Mergeable;
491-
break;
487+
return PullRequestMergeability.Mergeable;
492488
case 'CONFLICTING':
493-
parsed = PullRequestMergeability.Conflict;
494-
break;
489+
return PullRequestMergeability.NotMergeable;
495490
}
496-
if ((parsed !== PullRequestMergeability.Conflict) && (mergeStateStatus === 'BLOCKED')) {
497-
parsed = PullRequestMergeability.NotMergeable;
498-
}
499-
return parsed;
500491
}
501492

502493
export function parseGraphQLPullRequest(
@@ -522,7 +513,7 @@ export function parseGraphQLPullRequest(
522513
base: parseRef(graphQLPullRequest.baseRef?.name ?? graphQLPullRequest.baseRefName, graphQLPullRequest.baseRefOid, graphQLPullRequest.baseRepository),
523514
user: parseAuthor(graphQLPullRequest.author, githubRepository),
524515
merged: graphQLPullRequest.merged,
525-
mergeable: parseMergeability(graphQLPullRequest.mergeable, graphQLPullRequest.mergeStateStatus),
516+
mergeable: parseMergeability(graphQLPullRequest.mergeable),
526517
labels: graphQLPullRequest.labels.nodes,
527518
isDraft: graphQLPullRequest.isDraft,
528519
suggestedReviewers: parseSuggestedReviewers(graphQLPullRequest.suggestedReviewers),
@@ -596,7 +587,7 @@ export function parseGraphQLIssuesRequest(
596587
base: parseRef(graphQLPullRequest.baseRef?.name ?? graphQLPullRequest.baseRefName, graphQLPullRequest.baseRefOid, graphQLPullRequest.baseRepository),
597588
user: parseAuthor(graphQLPullRequest.author, githubRepository),
598589
merged: graphQLPullRequest.merged,
599-
mergeable: parseMergeability(graphQLPullRequest.mergeable, pullRequest.mergeStateStatus),
590+
mergeable: parseMergeability(graphQLPullRequest.mergeable),
600591
labels: graphQLPullRequest.labels.nodes,
601592
isDraft: graphQLPullRequest.isDraft,
602593
suggestedReviewers: parseSuggestedReviewers(graphQLPullRequest.suggestedReviewers),

src/test/builders/graphql/pullRequestBuilder.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export const PullRequestBuilder = createBuilderClass<PullRequestResponse>()({
6767
}),
6868
merged: { default: false },
6969
mergeable: { default: 'MERGEABLE' },
70-
mergeStateStatus: { default: 'CLEAN' },
7170
isDraft: { default: false },
7271
suggestedReviewers: { default: [] },
7372
}),

webviews/components/merge.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,15 @@ export const MergeStatus = ({ mergeable, isSimple }: { mergeable: PullRequestMer
145145
? null
146146
: mergeable === PullRequestMergeability.Mergeable
147147
? checkIcon
148-
: (mergeable === PullRequestMergeability.NotMergeable || mergeable === PullRequestMergeability.Conflict)
148+
: mergeable === PullRequestMergeability.NotMergeable
149149
? deleteIcon
150150
: pendingIcon}
151151
<div>
152-
{(mergeable) === PullRequestMergeability.Mergeable
152+
{mergeable === PullRequestMergeability.Mergeable
153153
? 'This branch has no conflicts with the base branch.'
154-
: mergeable === PullRequestMergeability.Conflict
154+
: mergeable === PullRequestMergeability.NotMergeable
155155
? 'This branch has conflicts that must be resolved.'
156-
: mergeable === PullRequestMergeability.NotMergeable
157-
? 'Branch protection policy must be fulfilled before merging.'
158-
: 'Checking if this branch can be merged...'}
156+
: 'Checking if this branch can be merged...'}
159157
</div>
160158
</div>
161159
);

webviews/editorWebview/index.css

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,6 @@ body .comment-container .review-comment-header {
235235
width: 16px;
236236
}
237237

238-
#status-checks .avatar-link svg {
239-
width: 24px;
240-
margin-right: 0px;
241-
vertical-align: middle;
242-
}
243-
244-
.status-check .avatar-link .avatar-icon {
245-
margin-right: 0px;
246-
}
247-
248238
#status-checks .merge-select-container {
249239
display: flex;
250240
align-items: center;

0 commit comments

Comments
 (0)