forked from microsoft/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache.ts
More file actions
57 lines (50 loc) · 1.82 KB
/
cache.ts
File metadata and controls
57 lines (50 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { vscode } from './message';
import { PullRequestStateEnum, IAccount, ReviewState, ILabel, MergeMethod, MergeMethodsAvailability } from '../src/github/interface';
import { TimelineEvent } from '../src/common/timelineEvent';
import { ReposGetCombinedStatusForRefResponse } from '@octokit/rest';
export interface PullRequest {
number: number;
title: string;
url: string;
createdAt: string;
body: string;
bodyHTML?: string;
author: IAccount;
state: PullRequestStateEnum;
events: TimelineEvent[];
isCurrentlyCheckedOut: boolean;
base: string;
head: string;
labels: ILabel[];
commitsCount: number;
repositoryDefaultBranch: any;
canEdit: boolean;
pendingCommentText?: string;
pendingCommentDrafts?: { [key: string]: string; };
status: ReposGetCombinedStatusForRefResponse;
mergeable: boolean;
defaultMergeMethod: MergeMethod;
mergeMethodsAvailability: MergeMethodsAvailability;
supportsGraphQl: boolean;
reviewers: ReviewState[];
}
export function getState(): PullRequest {
return vscode.getState() || {};
}
export function setState(pullRequest: PullRequest): void {
let oldPullRequest = getState();
if (oldPullRequest.number && oldPullRequest.number === pullRequest.number) {
pullRequest = Object.assign(pullRequest, {
pendingCommentText: oldPullRequest.pendingCommentText
});
}
vscode.setState(pullRequest);
}
export function updateState(data: Partial<PullRequest>): void {
const pullRequest = vscode.getState();
vscode.setState(Object.assign(pullRequest, data));
}