Skip to content

Commit

Permalink
Test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dgellow committed Feb 2, 2024
1 parent 7164741 commit 80fb83a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,12 @@ export class Manifest {
// Filter out commits that are just release commits for multiple packages
for (const [path, commits] of Object.entries(commitsPerPath)) {
commitsPerPath[path] = commits.filter(commit => {
if (commit.message.trim().startsWith('chore: release ')) {
if (
commit.pullRequest?.baseBranchName &&
commit.message
.trim()
.startsWith(`chore: release ${commit.pullRequest.baseBranchName}`)
) {
this.logger.debug(
`ignoring release commit for multi-packages PR: '${commit.message}' (${commit.sha})`
);
Expand Down
54 changes: 54 additions & 0 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,60 @@ describe('Manifest', () => {
snapshot(dateSafe(pullRequests[0].body.toString()));
});

it('should ignore multiple package release commits', async () => {
mockReleases(sandbox, github, [
{
id: 123456,
sha: 'abc123',
tagName: 'pkg1-v1.0.0',
url: 'https://github.com/fake-owner/fake-repo/releases/tag/pkg1-v1.0.0',
},
{
id: 654321,
sha: 'def234',
tagName: 'pkg2-v0.2.3',
url: 'https://github.com/fake-owner/fake-repo/releases/tag/pkg2-v0.2.3',
},
]);
mockCommits(sandbox, github, [
{
sha: 'def234',
message: 'chore: release main',
files: [],
pullRequest: {
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 123,
title: 'chore: release main',
body: '',
labels: [],
files: [],
sha: 'def234',
},
},
]);
const manifest = new Manifest(
github,
'main',
{
'path/a': {
releaseType: 'simple',
component: 'pkg1',
},
'path/b': {
releaseType: 'simple',
component: 'pkg2',
},
},
{
'path/a': Version.parse('1.0.0'),
'path/b': Version.parse('0.2.3'),
}
);
const pullRequests = await manifest.buildPullRequests([], []);
expect(pullRequests).lengthOf(0);
});

it('should allow creating multiple pull requests', async () => {
mockReleases(sandbox, github, [
{
Expand Down

0 comments on commit 80fb83a

Please sign in to comment.