@remogram/provider-gitlab-api 0.1.0-beta.0 → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +31 -7
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
gitAheadBehind,
|
|
10
10
|
ERROR_CODES,
|
|
11
11
|
forgeError,
|
|
12
|
+
forgeIngestCapabilityFacts,
|
|
12
13
|
} from '@remogram/core';
|
|
13
14
|
|
|
14
15
|
const PUBLIC_GITLAB_HOST = 'gitlab.com';
|
|
@@ -114,6 +115,25 @@ export async function gitlabFetch(config, parsed, path, options = {}) {
|
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
const MAX_CHECK_PAGES = 50;
|
|
119
|
+
const GITLAB_PAGE_SIZE = 100;
|
|
120
|
+
|
|
121
|
+
export async function gitlabFetchPaginated(config, parsed, path) {
|
|
122
|
+
const all = [];
|
|
123
|
+
for (let page = 1; page <= MAX_CHECK_PAGES; page += 1) {
|
|
124
|
+
const separator = path.includes('?') ? '&' : '?';
|
|
125
|
+
const body = await gitlabFetch(
|
|
126
|
+
config,
|
|
127
|
+
parsed,
|
|
128
|
+
`${path}${separator}per_page=${GITLAB_PAGE_SIZE}&page=${page}`,
|
|
129
|
+
);
|
|
130
|
+
const items = Array.isArray(body) ? body : [];
|
|
131
|
+
all.push(...items);
|
|
132
|
+
if (items.length < GITLAB_PAGE_SIZE) break;
|
|
133
|
+
}
|
|
134
|
+
return all;
|
|
135
|
+
}
|
|
136
|
+
|
|
117
137
|
export function providerCapabilities() {
|
|
118
138
|
return {
|
|
119
139
|
commands: STRUCTURED_COMMANDS,
|
|
@@ -121,8 +141,9 @@ export function providerCapabilities() {
|
|
|
121
141
|
check_sources: ['commit_statuses', 'pipelines'],
|
|
122
142
|
mergeability_confidence: 'derived',
|
|
123
143
|
host_binding: 'verified_remote_host',
|
|
124
|
-
pagination: '
|
|
144
|
+
pagination: 'supported',
|
|
125
145
|
write_support: false,
|
|
146
|
+
...forgeIngestCapabilityFacts(),
|
|
126
147
|
};
|
|
127
148
|
}
|
|
128
149
|
|
|
@@ -143,7 +164,6 @@ export async function repoStatus(ctx) {
|
|
|
143
164
|
|
|
144
165
|
export async function refsCompare(ctx, baseRef, headRef) {
|
|
145
166
|
apiBase(ctx.config, ctx.parsed);
|
|
146
|
-
requireToken();
|
|
147
167
|
assertGitRef(baseRef, 'base');
|
|
148
168
|
assertGitRef(headRef, 'head');
|
|
149
169
|
const baseSha = gitRevParse(ctx.cwd, baseRef);
|
|
@@ -239,20 +259,24 @@ export async function prChecks(ctx, opts) {
|
|
|
239
259
|
});
|
|
240
260
|
}
|
|
241
261
|
|
|
242
|
-
const [
|
|
243
|
-
|
|
244
|
-
|
|
262
|
+
const [statusRecords, pipelineRecords] = await Promise.all([
|
|
263
|
+
gitlabFetchPaginated(
|
|
264
|
+
ctx.config,
|
|
265
|
+
ctx.parsed,
|
|
266
|
+
projectApiPath(ctx.config, 'repository', 'commits', sha, 'statuses'),
|
|
267
|
+
),
|
|
268
|
+
gitlabFetchPaginated(
|
|
245
269
|
ctx.config,
|
|
246
270
|
ctx.parsed,
|
|
247
271
|
`${projectApiPath(ctx.config, 'pipelines')}?sha=${encodeURIComponent(sha)}`,
|
|
248
272
|
),
|
|
249
273
|
]);
|
|
250
|
-
const mappedStatuses =
|
|
274
|
+
const mappedStatuses = statusRecords.map((status) => ({
|
|
251
275
|
context: sanitizeField(status.name || status.context),
|
|
252
276
|
state: normalizeStatusState(status.status),
|
|
253
277
|
description: sanitizeField(status.description || status.status),
|
|
254
278
|
}));
|
|
255
|
-
const mappedPipelines =
|
|
279
|
+
const mappedPipelines = pipelineRecords.map((pipeline) => ({
|
|
256
280
|
context: sanitizeField(pipeline.name || `pipeline:${pipeline.id}`),
|
|
257
281
|
state: normalizeStatusState(pipeline.status),
|
|
258
282
|
description: sanitizeField(pipeline.status),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remogram/provider-gitlab-api",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
4
|
"description": "GitLab API provider for remogram",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@remogram/core": "0.1.0-beta.
|
|
25
|
+
"@remogram/core": "0.1.0-beta.1"
|
|
26
26
|
}
|
|
27
27
|
}
|