forked from danger/danger-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GitLabDSL.ts
107 lines (98 loc) · 3.71 KB
/
GitLabDSL.ts
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Please don't have includes in here that aren't inside the DSL folder, or the d.ts/flow defs break
// TODO: extract out from BitBucket specifically, or create our own type
import { Gitlab } from "@gitbeaker/node"
import { RepoMetaData } from "./BitBucketServerDSL"
import { UserExtendedSchema } from "@gitbeaker/core/dist/types/resources/Users"
import { MergeRequestSchema, UpdateMergeRequestOptions } from "@gitbeaker/core/dist/types/resources/MergeRequests"
import { MergeRequestLevelMergeRequestApprovalSchema } from "@gitbeaker/core/dist/types/resources/MergeRequestApprovals"
import { MergeRequestNoteSchema } from "@gitbeaker/core/dist/types/resources/MergeRequestNotes"
import { BaseRequestOptions } from "@gitbeaker/core/dist/types/infrastructure/RequestHelper"
import { CommitDiffSchema, CommitSchema } from "@gitbeaker/core/dist/types/resources/Commits"
import { RepositoryCompareSchema } from "@gitbeaker/core/dist/types/resources/Repositories"
// getPlatformReviewDSLRepresentation
export interface GitLabJSONDSL {
/** Info about the repo */
metadata: RepoMetaData
/** Info about the merge request */
mr: GitLabMR
/** All of the individual commits in the merge request */
commits: GitLabMRCommit[]
/** Merge Request-level MR approvals Configuration */
approvals: GitLabApproval
}
// danger.gitlab
/** The GitLab metadata for your MR */
export interface GitLabDSL extends GitLabJSONDSL {
utils: {
fileContents(path: string, repoSlug?: string, ref?: string): Promise<string>
}
api: InstanceType<typeof Gitlab>
}
// ---
// JSON responses from API
// can be removed
export interface GitLabUserProfile extends UserExtendedSchema {}
export interface GitlabUpdateMr extends UpdateMergeRequestOptions, BaseRequestOptions {}
export interface GitLabApproval extends MergeRequestLevelMergeRequestApprovalSchema {}
export interface GitLabMRChange extends CommitDiffSchema {}
export interface GitLabRepositoryCompare extends RepositoryCompareSchema {}
export interface GitLabMRCommit extends CommitSchema {}
// ^ can be removed
export interface GitLabInlineNote extends MergeRequestNoteSchema {
type: "DiffNote" | "DiscussionNote" | null // XXX: other types? null means "normal comment"
}
/** TODO: These need more comments from someone who uses GitLab, see GitLabDSL.ts in the danger-js repo */
export interface GitLabMR extends MergeRequestSchema {
subscribed: boolean
changes_count: string
latest_build_started_at: string
latest_build_finished_at: string
first_deployed_to_production_at: string | null
pipeline: {
id: number
sha: string
ref: string
status: "canceled" | "failed" | "pending" | "running" | "skipped" | "success"
web_url: string
}
diff_refs: {
base_sha: string
head_sha: string
start_sha: string
}
diverged_commits_count: number
rebase_in_progress: boolean
approvals_before_merge: null
//
/** Access rights for the user who created the MR */
user: {
/** Does the author have access to merge? */
can_merge: boolean
}
merge_error: null
allow_collaboration: boolean
allow_maintainer_to_push: boolean
}
export interface GitLabMRChanges extends MergeRequestSchema {
/** Access rights for the user who created the MR */
user: {
/** Does the author have access to merge? */
can_merge: boolean
}
merge_error: null
allow_collaboration: boolean
allow_maintainer_to_push: boolean
}
export interface GitLabNote extends MergeRequestNoteSchema {
type: "DiffNote" | "DiscussionNote" | null // XXX: other types? null means "normal comment"
}
export interface GitLabDiscussionTextPosition {
position_type: "text"
base_sha: string
start_sha: string
head_sha: string
new_path: string
new_line: number
old_path: string
old_line: number | null
}