瀏覽代碼

Fixes more serialization issues w/ commit details

main
Eric Amodio 2 年之前
父節點
當前提交
674b28f678
共有 3 個文件被更改,包括 26 次插入6 次删除
  1. +19
    -0
      src/git/models/issue.ts
  2. +3
    -3
      src/git/models/pullRequest.ts
  3. +4
    -3
      src/webviews/commitDetails/commitDetailsWebviewView.ts

+ 19
- 0
src/git/models/issue.ts 查看文件

@ -18,6 +18,25 @@ export interface IssueOrPullRequest {
readonly closed: boolean;
}
export function serializeIssueOrPullRequest(value: IssueOrPullRequest): IssueOrPullRequest {
const serialized: IssueOrPullRequest = {
type: value.type,
provider: {
id: value.provider.id,
name: value.provider.name,
domain: value.provider.domain,
icon: value.provider.icon,
},
id: value.id,
title: value.title,
url: value.url,
date: value.date,
closedDate: value.closedDate,
closed: value.closed,
};
return serialized;
}
export namespace IssueOrPullRequest {
export function getMarkdownIcon(issue: IssueOrPullRequest): string {
if (issue.type === IssueOrPullRequestType.PullRequest) {

+ 3
- 3
src/git/models/pullRequest.ts 查看文件

@ -24,8 +24,8 @@ export interface PullRequestShape extends IssueOrPullRequest {
readonly mergedDate?: Date;
}
export function toPullRequestShape(value: PullRequest): PullRequestShape {
const shape: PullRequestShape = {
export function serializePullRequest(value: PullRequest): PullRequestShape {
const serialized: PullRequestShape = {
type: value.type,
provider: {
id: value.provider.id,
@ -47,7 +47,7 @@ export function toPullRequestShape(value: PullRequest): PullRequestShape {
state: value.state,
mergedDate: value.mergedDate,
};
return shape;
return serialized;
}
export class PullRequest implements PullRequestShape {

+ 4
- 3
src/webviews/commitDetails/commitDetailsWebviewView.ts 查看文件

@ -9,8 +9,9 @@ import { isCommit } from '../../git/models/commit';
import type { GitFileChange } from '../../git/models/file';
import { GitFile } from '../../git/models/file';
import type { IssueOrPullRequest } from '../../git/models/issue';
import { serializeIssueOrPullRequest } from '../../git/models/issue';
import type { PullRequest } from '../../git/models/pullRequest';
import { toPullRequestShape } from '../../git/models/pullRequest';
import { serializePullRequest } from '../../git/models/pullRequest';
import type { GitRevisionReference } from '../../git/models/reference';
import { Logger } from '../../logger';
import type { ShowCommitInGraphCommandArgs } from '../../plus/webviews/graph/graphWebview';
@ -320,8 +321,8 @@ export class CommitDetailsWebviewView extends WebviewViewBase
// commits: commitChoices,
preferences: current.preferences,
selected: details,
autolinkedIssues: current.autolinkedIssues,
pullRequest: current.pullRequest != null ? toPullRequestShape(current.pullRequest) : undefined,
autolinkedIssues: current.autolinkedIssues?.map(serializeIssueOrPullRequest),
pullRequest: current.pullRequest != null ? serializePullRequest(current.pullRequest) : undefined,
dateFormat: dateFormat,
});
return state;

Loading…
取消
儲存