Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
token?: string;
logger?: Logger;
proxy?: ProxyOption;
fetch?: any;

Check warning on line 86 in src/github.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
}

type CommitFilter = (commit: Commit) => boolean;
Expand Down Expand Up @@ -574,7 +574,7 @@
}
)) {
// Paginate plugin doesn't have types for listing files on a commit
const data = resp.data as any as {files: {filename: string}[]};

Check warning on line 577 in src/github.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
for (const f of data.files || []) {
if (f.filename) {
files.push(f.filename);
Expand Down Expand Up @@ -1169,6 +1169,20 @@
draft: !!options?.draft,
labels: pullRequest.labels,
});
if (prNumber === 0) {
this.logger.warn(
'no code changes detected, skipping pull request creation'
);
return {
headBranchName: pullRequest.headBranchName,
baseBranchName: targetBranch,
number: 0,
title: pullRequest.title,
body: pullRequest.body,
labels: pullRequest.labels,
files: [],
};
}
return await this.getPullRequest(prNumber);
}
);
Expand Down
27 changes: 27 additions & 0 deletions test/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,33 @@ describe('GitHub', () => {
});
});

describe('createPullRequest', () => {
it('should not call getPullRequest when no code changes detected', async () => {
const createPullRequestStub = sandbox
.stub(codeSuggester, 'createPullRequest')
.resolves(0);
const getPullRequestStub = sandbox.stub(github, 'getPullRequest');

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const pullRequest = await (github as any).createPullRequest(
{
headBranchName: 'release-please--branches--main',
baseBranchName: 'main',
title: 'Release v1.0.0',
body: 'Release body',
labels: ['release-please'],
},
'main',
'commit message',
[]
);

expect(pullRequest.number).to.eql(0);
sinon.assert.calledOnce(createPullRequestStub);
sinon.assert.notCalled(getPullRequestStub);
});
});

describe('buildChangeSet', () => {
it('should merge updates for the same file', async () => {
const manifestPath = '.release-please-manifest.json';
Expand Down
Loading