Skip to content

Commit

Permalink
Fix body when auto-generating release notes (and updating) GitHub rel…
Browse files Browse the repository at this point in the history
…eases
  • Loading branch information
webpro committed Feb 22, 2022
1 parent c20d9d0 commit 2c42a8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/plugin/github/GitHub.js
Expand Up @@ -193,10 +193,10 @@ class GitHub extends Release {
const { owner, project: repo } = this.getContext('repo');
const { releaseName, draft = false, preRelease = false, autoGenerate = false } = this.options;
const { tagName } = this.config.getContext();
const { version, releaseNotes } = this.getContext();
const { version, releaseNotes, isUpdate } = this.getContext();
const { isPreRelease } = parseVersion(version);
const name = format(releaseName, this.config.getContext());
const body = autoGenerate ? '' : releaseNotes || '';
const body = autoGenerate ? (isUpdate ? null : '') : releaseNotes;

return Object.assign(options, {
owner,
Expand Down
8 changes: 3 additions & 5 deletions test/github.js
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: '', prerelease: true, draft: true } });
interceptCreate({ body: { tag_name: '2.0.2', name: 'Release 2.0.2', prerelease: true, draft: true } });

await runTasks(github);

Expand All @@ -99,7 +99,7 @@ test('should create a pre-release and draft release notes', async t => {
exec.restore();
});

test('should create auto generated release notes', async t => {
test('should create auto-generated release notes', async t => {
const options = {
git,
github: {
Expand All @@ -116,9 +116,7 @@ test('should create auto generated release notes', async t => {

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

await runTasks(github);

Expand Down
4 changes: 2 additions & 2 deletions test/stub/github.js
Expand Up @@ -44,7 +44,7 @@ const interceptCreate = ({
host = 'github.com',
owner = 'user',
project = 'repo',
body: { tag_name, name = '', body = '', prerelease = false, draft = false, generate_release_notes = false }
body: { tag_name, name = '', generate_release_notes = false, body = null, prerelease = false, draft = false }
} = {}) => {
nock(api)
.post(`/repos/${owner}/${project}/releases`, {
Expand Down Expand Up @@ -77,7 +77,7 @@ const interceptUpdate = ({
api = 'https://api.github.com',
owner = 'user',
project = 'repo',
body: { tag_name, name = '', body = '', prerelease = false, draft = false, generate_release_notes = false }
body: { tag_name, name = '', body = null, 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 2c42a8e

Please sign in to comment.