/
GitLabDSL.ts
293 lines (265 loc) · 6.81 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
// 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"
// 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
export interface GitLabUser {
id: number
name: string
username: string
state: "active" | "blocked"
avatar_url: string | null
web_url: string
}
export interface GitLabUserProfile extends GitLabUser {
created_at: string
bio: string | null
location: string | null
public_email: string
skype: string
linkedin: string
twitter: string
website_url: string
organization: string
last_sign_in_at: string
confirmed_at: string
theme_id: number
last_activity_on: string
color_scheme_id: number
projects_limit: number
current_sign_in_at: string
identities: [{ provider: string; extern_uid: string }]
can_create_group: boolean
can_create_project: boolean
two_factor_enabled: boolean
external: boolean
private_profile: boolean
}
export interface GitLabMRBase {
/** The MR's id */
id: number
/** The unique ID for this MR */
iid: number
/** The project ID for this MR */
project_id: number
/** The given name of the MR */
title: string
/** The body text describing the MR */
description: string
/** The MR's current availability */
state: "closed" | "open" | "locked" | "merged"
/** When was the MR made */
created_at: string
/** When was the MR updated */
updated_at: string
/** What branch is this MR being merged into */
target_branch: string
/** What branch is this MR come from */
source_branch: string
/** How many folks have given it an upvote */
upvotes: number
/** How many folks have given it an downvote */
downvotes: number
/** Who made it */
author: GitLabUser
/** Access rights for the user who created the MR */
user: {
/** Does the author have access to merge? */
can_merge: boolean
}
/** Who was assigned as the person to review */
assignee?: GitLabUser
assignees: GitLabUser[]
/** Users who were added as reviewers to the MR */
reviewers: GitLabUser[]
source_project_id: number
target_project_id: number
labels: string[]
work_in_progress: boolean
milestone: {
id: number
iid: number
project_id: number
title: string
description: string
state: "closed" | "active"
created_at: string
updated_at: string
due_date: string
start_date: string
web_url: string
}
merge_when_pipeline_succeeds: boolean
merge_status: "can_be_merged" // XXX: other statuses?
merge_error: null | null
sha: string
merge_commit_sha: string | null
user_notes_count: number
discussion_locked: null | null
should_remove_source_branch: boolean
force_remove_source_branch: boolean
allow_collaboration: boolean
allow_maintainer_to_push: boolean
web_url: string
time_stats: {
time_estimate: number
total_time_spent: number
human_time_estimate: number | null
human_total_time_spent: number | null
}
}
/** TODO: These need more comments from someone who uses GitLab, see GitLabDSL.ts in the danger-js repo */
export interface GitLabMR extends GitLabMRBase {
squash: boolean
subscribed: boolean
changes_count: string
merged_by: GitLabUser
merged_at: string
closed_by: GitLabUser | null
closed_at: string | null
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 | null
}
export interface GitLabMRChange {
old_path: string
new_path: string
a_mode: string
b_mode: string
diff: string
new_file: boolean
renamed_file: boolean
deleted_file: boolean
}
export interface GitLabMRChanges extends GitLabMRBase {
changes: GitLabMRChange[]
}
export interface GitLabNote {
id: number
type: "DiffNote" | "DiscussionNote" | null // XXX: other types? null means "normal comment"
body: string
attachment: null // XXX: what can an attachment be?
author: GitLabUser
created_at: string
updated_at: string
system: boolean
noteable_id: number
noteable_type: "MergeRequest" // XXX: other types...?
resolvable: boolean
noteable_iid: number
}
export interface GitLabDiscussion {
id: string; //40 character hex
individual_note: boolean;
notes: GitLabNote[];
}
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
}
export interface GitLabDiscussionCreationOptions {
position?: GitLabDiscussionTextPosition
}
export interface GitLabInlineNote extends GitLabNote {
position: {
base_sha: string
start_sha: string
head_sha: string
old_path: string
new_path: string
position_type: "text" // XXX: other types?
old_line: number | null
new_line: number
}
resolvable: boolean
resolved: boolean
resolved_by: GitLabUser | null
}
export interface GitLabMRCommit {
id: string
short_id: string
created_at: string
parent_ids: string[]
title: string
message: string
author_name: string
author_email: string
authored_date: string
committer_name: string
committer_email: string
committed_date: string
}
export interface GitLabCommit {
id: string
short_id: string
title: string
author_name: string
author_email: string
created_at: string
}
export interface GitLabRepositoryCompare {
commit: GitLabCommit
commits: GitLabCommit[]
diffs: GitLabMRChange[]
compare_timeout: boolean
compare_same_ref: boolean
}
export interface GitLabApproval {
id: number
iid: number
project_id: number
title: string
description: string
state: "closed" | "open" | "locked" | "merged"
created_at: string
updated_at: string
merge_status: "can_be_merged"
approvals_required: number
approvals_left: number
approved_by?:
| {
user: GitLabUser
}[]
| GitLabUser[]
}