Skip to content

Commit

Permalink
change fix approach
Browse files Browse the repository at this point in the history
  • Loading branch information
kreddlear committed Aug 10, 2023
1 parent 930a6ba commit 9f873ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
12 changes: 6 additions & 6 deletions packages/cli/src/oclif/commands/promote.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ${metadataPromptHelper}`);
.filter(({ app_change_type }) => app_change_type === 'FEATURE_UPDATE')
.map(({ issue_id }) => `#${issue_id}`);

if (!_.isEmpty(appFeatureUpdates) || !_.isEmpty(issueFeatureUpdates)) {
if (appFeatureUpdates || issueFeatureUpdates) {
this.log(
`Feature updates: ${[
...appFeatureUpdates,
Expand All @@ -113,15 +113,15 @@ ${metadataPromptHelper}`);
.filter(({ app_change_type }) => app_change_type === 'BUGFIX')
.map(({ issue_id }) => `#${issue_id}`);

if (!_.isEmpty(appBugfixes) || !_.isEmpty(issueBugfixes)) {
if (appBugfixes || issueBugfixes) {
this.log(`Bug fixes: ${[...appBugfixes, issueBugfixes].join(', ')}`);
}

if (
_.isEmpty(appFeatureUpdates) &&
_.isEmpty(issueFeatureUpdates) &&
_.isEmpty(appBugfixes) &&
_.isEmpty(issueBugfixes)
!appFeatureUpdates &&
!issueFeatureUpdates &&
!appBugfixes &&
!issueBugfixes
) {
this.log(
`No metadata was found in the changelog. Remember, you can associate the changelog with issues or triggers/actions.\n\n${metadataPromptHelper}`
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/tests/utils/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ describe('changelog utils', () => {
it('should be forgiving on the markdown format', async () => {
const { appMetadata, issueMetadata, changelog } =
await changelogUtil.getVersionChangelog('0.0.1', appDir);
should(appMetadata.length).equal(0);
should(issueMetadata.length).equal(0);
should(appMetadata).equal(undefined);
should(issueMetadata).equal(undefined);
changelog.should.equal('initial release\n\njust for internal testing');
});

Expand Down Expand Up @@ -74,8 +74,8 @@ describe('changelog utils', () => {
it('should not return metadata if it is not found', async () => {
const { appMetadata, issueMetadata, changelog } =
await changelogUtil.getVersionChangelog('1.0.0', appDir);
should(appMetadata.length).equal(0);
should(issueMetadata.length).equal(0);
should(appMetadata).equal(undefined);
should(issueMetadata).equal(undefined);
changelog.should.equal('* Removing beta "label".\n* Minor docs fixes.');
});

Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/utils/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const isAppMetadata = (obj) =>

const isIssueMetadata = (obj) => obj?.app_change_type && obj?.issue_id;

// Turns an empty array into undefined so it will not be present in the body when sent
const absentIfEmpty = (arr) => (arr.length === 0 ? undefined : arr);

const getChangelogFromMarkdown = (version, markdown) => {
const lines = markdown
.replace(/\r\n/g, '\n')
Expand Down Expand Up @@ -53,8 +56,8 @@ const getChangelogFromMarkdown = (version, markdown) => {

return {
changelog: changelog.join('\n').trim(),
appMetadata,
issueMetadata,
appMetadata: absentIfEmpty(appMetadata),
issueMetadata: absentIfEmpty(issueMetadata),
};
};

Expand Down

0 comments on commit 9f873ba

Please sign in to comment.