Skip to content

Commit 350f0a1

Browse files
committed
fix: use git tag as release description if no release notes exists
1 parent 54c787b commit 350f0a1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module.exports = async (pluginConfig, context) => {
7070
debug('Update git tag %o with commit %o and release description', gitTag, gitHead);
7171
await got.post(urlJoin(gitlabApiUrl, `/projects/${encodedRepoId}/repository/tags/${encodedGitTag}/release`), {
7272
...apiOptions,
73-
json: {tag_name: gitTag, description: notes}, // eslint-disable-line camelcase
73+
json: {tag_name: gitTag, description: notes && notes.trim() ? notes : gitTag}, // eslint-disable-line camelcase
7474
});
7575

7676
if (assetsList.length > 0) {

test/publish.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,26 @@ test.serial('Publish a release with one asset and custom label', async t => {
140140
t.true(gitlab.isDone());
141141
t.true(gitlabAssetLink.isDone());
142142
});
143+
144+
test.serial('Publish a release with missing releasae notes', async t => {
145+
const owner = 'test_user';
146+
const repo = 'test_repo';
147+
const env = {GITLAB_TOKEN: 'gitlab_token'};
148+
const pluginConfig = {};
149+
const nextRelease = {gitHead: '123', gitTag: 'v1.0.0'};
150+
const options = {repositoryUrl: `https://gitlab.com/${owner}/${repo}.git`};
151+
const encodedRepoId = encodeURIComponent(`${owner}/${repo}`);
152+
const encodedGitTag = encodeURIComponent(nextRelease.gitTag);
153+
const gitlab = authenticate(env)
154+
.post(`/projects/${encodedRepoId}/repository/tags/${encodedGitTag}/release`, {
155+
tag_name: nextRelease.gitTag,
156+
description: nextRelease.gitTag,
157+
})
158+
.reply(200);
159+
160+
const result = await publish(pluginConfig, {env, options, nextRelease, logger: t.context.logger});
161+
162+
t.is(result.url, `https://gitlab.com/${encodedRepoId}/tags/${encodedGitTag}`);
163+
t.deepEqual(t.context.log.args[0], ['Published GitLab release: %s', nextRelease.gitTag]);
164+
t.true(gitlab.isDone());
165+
});

0 commit comments

Comments
 (0)