Skip to content

Commit

Permalink
Use empty string (not null) for release notes body in GitHub release …
Browse files Browse the repository at this point in the history
…request (fixes ##855)
  • Loading branch information
webpro committed Jan 15, 2022
1 parent 66c6f3b commit bdbc2ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/plugin/github/GitHub.js
Expand Up @@ -192,7 +192,7 @@ class GitHub extends Release {
const { version, releaseNotes } = this.getContext();
const { isPreRelease } = parseVersion(version);
const name = format(releaseName, this.config.getContext());
const body = autoGenerate ? null : releaseNotes;
const body = autoGenerate ? '' : releaseNotes || '';

return Object.assign(options, {
owner,
Expand Down
6 changes: 3 additions & 3 deletions test/github.js
Expand Up @@ -15,7 +15,7 @@ const {
const tokenRef = 'GITHUB_TOKEN';
const pushRepo = 'git://github.com:user/repo';
const host = 'github.com';
const git = { changelog: null };
const git = { changelog: '' };
const requestErrorOptions = { request: { url: '', headers: {} }, response: { headers: {} } };

test.serial('should check token and perform checks', async t => {
Expand Down Expand Up @@ -89,7 +89,7 @@ test('should create a pre-release and draft release notes', async t => {

interceptAuthentication();
interceptCollaborator();
interceptCreate({ body: { tag_name: '2.0.2', name: 'Release 2.0.2', body: null, prerelease: true, draft: true } });
interceptCreate({ body: { tag_name: '2.0.2', name: 'Release 2.0.2', body: '', prerelease: true, draft: true } });

await runTasks(github);

Expand Down Expand Up @@ -244,7 +244,7 @@ test('should release to alternative host and proxy', async t => {
test('should release to git.pushRepo', async t => {
const remote = { api: 'https://my-custom-host.org/api/v3', host: 'my-custom-host.org' };
interceptCreate(Object.assign({ body: { tag_name: '1.0.1' } }, remote));
const options = { git: { pushRepo: 'upstream', changelog: null }, github: { tokenRef, skipChecks: true } };
const options = { git: { pushRepo: 'upstream', changelog: '' }, github: { tokenRef, skipChecks: true } };
const github = factory(GitHub, { options });
const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('1.0.0');
Expand Down
4 changes: 2 additions & 2 deletions test/stub/github.js
Expand Up @@ -40,7 +40,7 @@ const interceptCreate = ({
host = 'github.com',
owner = 'user',
project = 'repo',
body: { tag_name, name = '', body = null, prerelease = false, draft = false, generate_release_notes = false }
body: { tag_name, name = '', body = '', prerelease = false, draft = false, generate_release_notes = false }
} = {}) =>
nock(api)
.post(`/repos/${owner}/${project}/releases`, {
Expand Down Expand Up @@ -72,7 +72,7 @@ const interceptUpdate = ({
api = 'https://api.github.com',
owner = 'user',
project = 'repo',
body: { tag_name, name = '', body = null, prerelease = false, draft = false, generate_release_notes = false }
body: { tag_name, name = '', body = '', prerelease = false, draft = false, generate_release_notes = false }
} = {}) =>
nock(api)
.patch(`/repos/${owner}/${project}/releases/1`, { tag_name, name, body, draft, prerelease, generate_release_notes })
Expand Down

0 comments on commit bdbc2ca

Please sign in to comment.