Skip to content

Commit 8d87b4b

Browse files
committed
fix: handle undefined API prefix
1 parent c4d18d6 commit 8d87b4b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/publish.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@ const getRepoId = require('./get-repo-id');
77
module.exports = async (pluginConfig, {repositoryUrl}, {gitHead, gitTag, notes}, logger) => {
88
const {gitlabToken, gitlabUrl, gitlabApiPathPrefix} = resolveConfig(pluginConfig);
99
const repoId = encodeURIComponent(getRepoId(gitlabUrl, repositoryUrl));
10+
const apiUrl = urlJoin(gitlabUrl, gitlabApiPathPrefix);
1011

1112
debug('repoId: %o', repoId);
1213
debug('release name: %o', gitTag);
1314
debug('release ref: %o', gitHead);
1415

1516
try {
1617
// Test if the tag already exists
17-
await got.get(urlJoin(gitlabUrl, gitlabApiPathPrefix, `/projects/${repoId}/repository/tags/${gitTag}`), {
18+
await got.get(urlJoin(apiUrl, `/projects/${repoId}/repository/tags/${gitTag}`), {
1819
json: true,
1920
headers: {'Private-Token': gitlabToken},
2021
});
2122
debug('The git tag %o already exists, update the release description', gitTag);
2223
// Update the release notes
2324
await got.post(
24-
urlJoin(gitlabUrl, gitlabApiPathPrefix, `/projects/${repoId}/repository/tags/${gitTag}/release`),
25+
urlJoin(apiUrl, `/projects/${repoId}/repository/tags/${gitTag}/release`),
2526
{json: true, headers: {'Private-Token': gitlabToken}, body: {tag_name: gitTag, description: notes}} // eslint-disable-line camelcase
2627
);
2728
} catch (err) {
@@ -30,7 +31,7 @@ module.exports = async (pluginConfig, {repositoryUrl}, {gitHead, gitTag, notes},
3031
throw err;
3132
}
3233
debug('Create git tag %o with commit %o and release description', gitTag, gitHead);
33-
await got.post(urlJoin(gitlabUrl, gitlabApiPathPrefix, `/projects/${repoId}/repository/tags/${gitTag}/release`), {
34+
await got.post(urlJoin(apiUrl, `/projects/${repoId}/repository/tags/${gitTag}/release`), {
3435
json: true,
3536
headers: {'PRIVATE-TOKEN': gitlabToken},
3637
body: {tag_name: gitTag, ref: gitHead, release_description: notes}, // eslint-disable-line camelcase

lib/verify.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ module.exports = async (pluginConfig, {repositoryUrl}, logger) => {
2323
);
2424
}
2525

26-
logger.log('Verify GitLab authentication (%s)', urlJoin(gitlabUrl, gitlabApiPathPrefix));
26+
const apiUrl = urlJoin(gitlabUrl, gitlabApiPathPrefix);
27+
28+
logger.log('Verify GitLab authentication (%s)', apiUrl);
2729

2830
let projectAccess;
2931
let groupAccess;
3032

3133
try {
3234
({body: {permissions: {project_access: projectAccess, group_access: groupAccess}}} = await got.get(
33-
urlJoin(gitlabUrl, gitlabApiPathPrefix, `/projects/${encodeURIComponent(repoId)}`),
35+
urlJoin(apiUrl, `/projects/${encodeURIComponent(repoId)}`),
3436
{json: true, headers: {'Private-Token': gitlabToken}}
3537
));
3638
} catch (err) {

0 commit comments

Comments
 (0)