Selaa lähdekoodia

Adds more fields to PullRequest

main
Keith Daulton 1 vuosi sitten
committed by Keith Daulton
vanhempi
commit
1eea2ad3b4
4 muutettua tiedostoa jossa 110 lisäystä ja 25 poistoa
  1. +1
    -1
      .vscode/queries.github-graphql-nb
  2. +21
    -0
      src/git/models/pullRequest.ts
  3. +35
    -23
      src/plus/github/github.ts
  4. +53
    -1
      src/plus/github/models.ts

+ 1
- 1
.vscode/queries.github-graphql-nb
File diff suppressed because it is too large
Näytä tiedosto


+ 21
- 0
src/git/models/pullRequest.ts Näytä tiedosto

@ -14,6 +14,18 @@ export const enum PullRequestState {
Merged = 'Merged',
}
export const enum PullRequestReviewDecision {
Approved = 'Approved',
ChangesRequested = 'ChangesRequested',
ReviewRequired = 'ReviewRequired',
}
export const enum PullRequestMergeableState {
Unknown = 'Unknown',
Mergeable = 'Mergeable',
Conflicting = 'Conflicting',
}
export interface PullRequestRef {
owner: string;
repo: string;
@ -47,6 +59,9 @@ export interface PullRequestShape extends IssueOrPullRequest {
readonly isDraft?: boolean;
readonly additions?: number;
readonly deletions?: number;
readonly comments?: number;
readonly mergeableState?: PullRequestMergeableState;
readonly reviewDecision?: PullRequestReviewDecision;
readonly reviewRequests?: { isCodeOwner: boolean; reviewer: PullRequestMember }[];
readonly assignees?: PullRequestMember[];
}
@ -78,6 +93,7 @@ export function serializePullRequest(value: PullRequest): PullRequestShape {
},
state: value.state,
mergedDate: value.mergedDate,
mergeableState: value.mergeableState,
refs: value.refs
? {
head: {
@ -100,6 +116,8 @@ export function serializePullRequest(value: PullRequest): PullRequestShape {
isDraft: value.isDraft,
additions: value.additions,
deletions: value.deletions,
comments: value.comments,
reviewDecision: value.reviewDecision,
reviewRequests: value.reviewRequests,
assignees: value.assignees,
};
@ -159,10 +177,13 @@ export class PullRequest implements PullRequestShape {
public readonly date: Date,
public readonly closedDate?: Date,
public readonly mergedDate?: Date,
public readonly mergeableState?: PullRequestMergeableState,
public readonly refs?: PullRequestRefs,
public readonly isDraft?: boolean,
public readonly additions?: number,
public readonly deletions?: number,
public readonly comments?: number,
public readonly reviewDecision?: PullRequestReviewDecision,
public readonly reviewRequests?: PullRequestReviewer[],
public readonly assignees?: PullRequestMember[],
) {}

+ 35
- 23
src/plus/github/github.ts Näytä tiedosto

@ -2495,11 +2495,38 @@ function uniqueWithReasons(items: T[], lookup:
}
const prNodeProperties = `
assignees(first: 10) {
nodes {
login
avatarUrl
url
}
}
author {
login
avatarUrl
url
}
baseRefName
baseRefOid
baseRepository {
name
owner {
login
}
}
checksUrl
isDraft
isCrossRepository
isReadByViewer
headRefName
headRefOid
headRepository {
name
owner {
login
}
}
permalink
number
title
@ -2508,34 +2535,25 @@ additions
deletions
updatedAt
closedAt
mergeable
mergedAt
repository {
isFork
owner {
login
}
}
reviewDecision
mergedBy {
login
}
baseRefName
baseRefOid
baseRepository {
name
repository {
isFork
owner {
login
}
}
headRefName
headRefOid
headRepository {
name
repository {
isFork
owner {
login
}
}
reviewRequests {
reviewDecision
reviewRequests(first: 10) {
nodes {
asCodeOwner
id
@ -2548,13 +2566,7 @@ reviewRequests {
}
}
}
assignees(first: 10) {
nodes {
login
avatarUrl
url
}
}
totalCommentsCount
`;
const issueNodeProperties = `

+ 53
- 1
src/plus/github/models.ts Näytä tiedosto

@ -2,7 +2,12 @@ import type { Endpoints } from '@octokit/types';
import { GitFileIndexStatus } from '../../git/models/file';
import type { IssueLabel, IssueMember, IssueOrPullRequestType } from '../../git/models/issue';
import { Issue } from '../../git/models/issue';
import { PullRequest, PullRequestState } from '../../git/models/pullRequest';
import {
PullRequest,
PullRequestMergeableState,
PullRequestReviewDecision,
PullRequestState,
} from '../../git/models/pullRequest';
import type { RichRemoteProvider } from '../../git/remotes/richRemoteProvider';
export interface GitHubBlame {
@ -186,6 +191,50 @@ export namespace GitHubPullRequest {
return state === PullRequestState.Merged ? 'MERGED' : state === PullRequestState.Closed ? 'CLOSED' : 'OPEN';
}
export function fromReviewDecision(reviewDecision: GitHubPullRequestReviewDecision): PullRequestReviewDecision {
switch (reviewDecision) {
case 'APPROVED':
return PullRequestReviewDecision.Approved;
case 'CHANGES_REQUESTED':
return PullRequestReviewDecision.ChangesRequested;
case 'REVIEW_REQUIRED':
return PullRequestReviewDecision.ReviewRequired;
}
}
export function toReviewDecision(reviewDecision: PullRequestReviewDecision): GitHubPullRequestReviewDecision {
switch (reviewDecision) {
case PullRequestReviewDecision.Approved:
return 'APPROVED';
case PullRequestReviewDecision.ChangesRequested:
return 'CHANGES_REQUESTED';
case PullRequestReviewDecision.ReviewRequired:
return 'REVIEW_REQUIRED';
}
}
export function fromMergeableState(mergeableState: GitHubPullRequestMergeableState): PullRequestMergeableState {
switch (mergeableState) {
case 'MERGEABLE':
return PullRequestMergeableState.Mergeable;
case 'CONFLICTING':
return PullRequestMergeableState.Conflicting;
case 'UNKNOWN':
return PullRequestMergeableState.Unknown;
}
}
export function toMergeableState(mergeableState: PullRequestMergeableState): GitHubPullRequestMergeableState {
switch (mergeableState) {
case PullRequestMergeableState.Mergeable:
return 'MERGEABLE';
case PullRequestMergeableState.Conflicting:
return 'CONFLICTING';
case PullRequestMergeableState.Unknown:
return 'UNKNOWN';
}
}
export function fromDetailed(pr: GitHubDetailedPullRequest, provider: RichRemoteProvider): PullRequest {
return new PullRequest(
provider,
@ -201,6 +250,7 @@ export namespace GitHubPullRequest {
new Date(pr.updatedAt),
pr.closedAt == null ? undefined : new Date(pr.closedAt),
pr.mergedAt == null ? undefined : new Date(pr.mergedAt),
fromMergeableState(pr.mergeable),
{
head: {
exists: pr.headRepository != null,
@ -221,6 +271,8 @@ export namespace GitHubPullRequest {
pr.isDraft,
pr.additions,
pr.deletions,
pr.totalCommentsCount,
fromReviewDecision(pr.reviewDecision),
pr.reviewRequests.nodes.map(r => ({
isCodeOwner: r.asCodeOwner,
reviewer: {

Ladataan…
Peruuta
Tallenna