@remogram/provider-gitlab-api 0.1.0-beta.0 → 0.1.0-beta.2
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 +33 -8
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
gitAheadBehind,
|
|
10
10
|
ERROR_CODES,
|
|
11
11
|
forgeError,
|
|
12
|
+
forgeIngestCapabilityFacts,
|
|
13
|
+
apiProviderCommands,
|
|
12
14
|
} from '@remogram/core';
|
|
13
15
|
|
|
14
16
|
const PUBLIC_GITLAB_HOST = 'gitlab.com';
|
|
@@ -21,7 +23,7 @@ const AUTH_CAPABILITIES = [
|
|
|
21
23
|
'merge_plan',
|
|
22
24
|
'sync_plan',
|
|
23
25
|
];
|
|
24
|
-
const STRUCTURED_COMMANDS =
|
|
26
|
+
const STRUCTURED_COMMANDS = apiProviderCommands();
|
|
25
27
|
|
|
26
28
|
export function gitlabToken() {
|
|
27
29
|
return process.env.GITLAB_TOKEN || null;
|
|
@@ -114,6 +116,25 @@ export async function gitlabFetch(config, parsed, path, options = {}) {
|
|
|
114
116
|
});
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
const MAX_CHECK_PAGES = 50;
|
|
120
|
+
const GITLAB_PAGE_SIZE = 100;
|
|
121
|
+
|
|
122
|
+
export async function gitlabFetchPaginated(config, parsed, path) {
|
|
123
|
+
const all = [];
|
|
124
|
+
for (let page = 1; page <= MAX_CHECK_PAGES; page += 1) {
|
|
125
|
+
const separator = path.includes('?') ? '&' : '?';
|
|
126
|
+
const body = await gitlabFetch(
|
|
127
|
+
config,
|
|
128
|
+
parsed,
|
|
129
|
+
`${path}${separator}per_page=${GITLAB_PAGE_SIZE}&page=${page}`,
|
|
130
|
+
);
|
|
131
|
+
const items = Array.isArray(body) ? body : [];
|
|
132
|
+
all.push(...items);
|
|
133
|
+
if (items.length < GITLAB_PAGE_SIZE) break;
|
|
134
|
+
}
|
|
135
|
+
return all;
|
|
136
|
+
}
|
|
137
|
+
|
|
117
138
|
export function providerCapabilities() {
|
|
118
139
|
return {
|
|
119
140
|
commands: STRUCTURED_COMMANDS,
|
|
@@ -121,8 +142,9 @@ export function providerCapabilities() {
|
|
|
121
142
|
check_sources: ['commit_statuses', 'pipelines'],
|
|
122
143
|
mergeability_confidence: 'derived',
|
|
123
144
|
host_binding: 'verified_remote_host',
|
|
124
|
-
pagination: '
|
|
145
|
+
pagination: 'supported',
|
|
125
146
|
write_support: false,
|
|
147
|
+
...forgeIngestCapabilityFacts(),
|
|
126
148
|
};
|
|
127
149
|
}
|
|
128
150
|
|
|
@@ -143,7 +165,6 @@ export async function repoStatus(ctx) {
|
|
|
143
165
|
|
|
144
166
|
export async function refsCompare(ctx, baseRef, headRef) {
|
|
145
167
|
apiBase(ctx.config, ctx.parsed);
|
|
146
|
-
requireToken();
|
|
147
168
|
assertGitRef(baseRef, 'base');
|
|
148
169
|
assertGitRef(headRef, 'head');
|
|
149
170
|
const baseSha = gitRevParse(ctx.cwd, baseRef);
|
|
@@ -239,20 +260,24 @@ export async function prChecks(ctx, opts) {
|
|
|
239
260
|
});
|
|
240
261
|
}
|
|
241
262
|
|
|
242
|
-
const [
|
|
243
|
-
|
|
244
|
-
|
|
263
|
+
const [statusRecords, pipelineRecords] = await Promise.all([
|
|
264
|
+
gitlabFetchPaginated(
|
|
265
|
+
ctx.config,
|
|
266
|
+
ctx.parsed,
|
|
267
|
+
projectApiPath(ctx.config, 'repository', 'commits', sha, 'statuses'),
|
|
268
|
+
),
|
|
269
|
+
gitlabFetchPaginated(
|
|
245
270
|
ctx.config,
|
|
246
271
|
ctx.parsed,
|
|
247
272
|
`${projectApiPath(ctx.config, 'pipelines')}?sha=${encodeURIComponent(sha)}`,
|
|
248
273
|
),
|
|
249
274
|
]);
|
|
250
|
-
const mappedStatuses =
|
|
275
|
+
const mappedStatuses = statusRecords.map((status) => ({
|
|
251
276
|
context: sanitizeField(status.name || status.context),
|
|
252
277
|
state: normalizeStatusState(status.status),
|
|
253
278
|
description: sanitizeField(status.description || status.status),
|
|
254
279
|
}));
|
|
255
|
-
const mappedPipelines =
|
|
280
|
+
const mappedPipelines = pipelineRecords.map((pipeline) => ({
|
|
256
281
|
context: sanitizeField(pipeline.name || `pipeline:${pipeline.id}`),
|
|
257
282
|
state: normalizeStatusState(pipeline.status),
|
|
258
283
|
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.2",
|
|
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.2"
|
|
26
26
|
}
|
|
27
27
|
}
|