Skip to content

Commit

Permalink
feat(ng-dev/release): Allow retrieving the number of commits in the r…
Browse files Browse the repository at this point in the history
…elease notes (#180)

PR Close #180
  • Loading branch information
josephperrott committed Aug 27, 2021
1 parent 6829626 commit 2589dcd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ng-dev/release/notes/release-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export class ReleaseNotes {
return render(changelogTemplate, await this.generateRenderContext(), {rmWhitespace: true});
}

/** Retrieve the number of commits included in the release notes after filtering and deduping. */
async getCommitCountInReleaseNotes() {
const context = await this.generateRenderContext();
return context.commits.filter(context.includeInReleaseNotes()).length;
}

/**
* Gets the URL fragment for the release notes. The URL fragment identifier
* can be used to point to a specific changelog entry through an URL.
Expand Down
14 changes: 14 additions & 0 deletions ng-dev/release/publish/test/release-notes/generation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,18 @@ describe('release notes generation', () => {
`);
});
});

it('should determine the number of commits included in the entry', async () => {
SandboxGitRepo.withInitialCommit(githubConfig)
.createTagForHead('0.0.0')
.commit('fix: first thing fixed')
.commit('feat: first new thing')
.commit('feat: second new thing')
.commit('build: rework everything')
.commit('fix: fix what we broke');

const releaseNotes = await ReleaseNotes.forRange(parse('0.0.1'), '0.0.0', 'HEAD');

expect(await releaseNotes.getCommitCountInReleaseNotes()).toBe(4);
});
});

0 comments on commit 2589dcd

Please sign in to comment.