@open-cr-agent/vcs-gitlab 0.11.0 → 0.12.0
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/dist/target.js +8 -4
- package/package.json +3 -3
package/dist/target.js
CHANGED
|
@@ -42,8 +42,8 @@ export async function gitlabApi(options, named, what) {
|
|
|
42
42
|
throw new OcraError("CONFIG_CREDENTIALS_MISSING", `${what} needs a GitLab token in GITLAB_TOKEN with the api scope and the Developer role: a project access token, or on GitLab.com Free a personal access token of a dedicated account (CI_JOB_TOKEN cannot post comments)`);
|
|
43
43
|
}
|
|
44
44
|
const origin = await options.origin();
|
|
45
|
-
const project = named ?? env.CI_PROJECT_ID ?? gitlabProject(origin);
|
|
46
45
|
const apiUrl = gitlabApiUrl(env.CI_API_V4_URL, remoteHost(origin), options.warn);
|
|
46
|
+
const project = named ?? env.CI_PROJECT_ID ?? gitlabProject(origin, apiUrl);
|
|
47
47
|
const api = new GitLabApi(project, {
|
|
48
48
|
token,
|
|
49
49
|
baseUrl: apiUrl,
|
|
@@ -90,10 +90,14 @@ function remoteHost(url) {
|
|
|
90
90
|
return /^(?:[^@\s/]+@)?([^:/\s\\]+):(?![\\/])/.exec(url)?.[1]?.toLowerCase();
|
|
91
91
|
}
|
|
92
92
|
// The project behind the origin remote: any host, since GitLab runs on many.
|
|
93
|
-
|
|
93
|
+
// An HTTPS remote of an instance installed under a relative URL root
|
|
94
|
+
// (https://example.com/gitlab/group/project) has the API's root before it.
|
|
95
|
+
function gitlabProject(url, apiUrl) {
|
|
94
96
|
const match = url && /^(?:[\w+.-]+:\/\/[^/]+\/|[^@\s]+@[^:]+:)(.+?)(?:\.git)?\/?$/.exec(url);
|
|
95
|
-
if (!match?.[1]) {
|
|
97
|
+
if (!url || !match?.[1]) {
|
|
96
98
|
throw new OcraError("CONFIG_INVALID", "Cannot tell which GitLab project this is; pass --project <id|path>");
|
|
97
99
|
}
|
|
98
|
-
|
|
100
|
+
const root = new URL(apiUrl).pathname.replace(/\/api\/v4\/?$/, "").replace(/^\/+/, "");
|
|
101
|
+
const underRoot = root && /^[\w+.-]+:\/\//.test(url) && match[1].startsWith(`${root}/`);
|
|
102
|
+
return underRoot ? match[1].slice(root.length + 1) : match[1];
|
|
99
103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-cr-agent/vcs-gitlab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "GitLab merge request adapter for Open-CR-Agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-review",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"!dist/**/*.map"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@open-cr-agent/core": "0.
|
|
37
|
-
"@open-cr-agent/vcs-platform": "0.
|
|
36
|
+
"@open-cr-agent/core": "0.12.0",
|
|
37
|
+
"@open-cr-agent/vcs-platform": "0.12.0",
|
|
38
38
|
"zod": "^4.6.6"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|