Skip to content

Commit 78630a2

Browse files
meorphismeorphis
andauthored
do not create release pr if there is only a merge commit from release-please (#209)
Co-authored-by: meorphis <[email protected]>
1 parent 5565092 commit 78630a2

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

src/manifest.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -835,16 +835,14 @@ export class Manifest {
835835
openPullRequests.find(pr => pr.headBranchName === branchName) ||
836836
snoozedPullRequests.find(pr => pr.headBranchName === branchName);
837837

838-
const releasePullRequest = commitsPerPath[path]
839-
? await strategy.buildReleasePullRequest({
840-
commits: pathCommits,
841-
latestRelease,
842-
draft: config.draftPullRequest ?? this.draftPullRequest,
843-
labels: this.labels,
844-
existingPullRequest: existingPR,
845-
manifestPath: this.manifestPath,
846-
})
847-
: undefined;
838+
const releasePullRequest = await strategy.buildReleasePullRequest({
839+
commits: commitsPerPath[path],
840+
latestRelease,
841+
draft: config.draftPullRequest ?? this.draftPullRequest,
842+
labels: this.labels,
843+
existingPullRequest: existingPR,
844+
manifestPath: this.manifestPath,
845+
});
848846
this.logger.debug(`path: ${path}`);
849847
this.logger.debug(
850848
`releasePullRequest.headRefName: ${releasePullRequest?.headRefName}`

src/strategies/base.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
import {DefaultVersioningStrategy} from '../versioning-strategies/default';
2828
import {DefaultChangelogNotes} from '../changelog-notes/default';
2929
import {Update} from '../update';
30-
import {ConventionalCommit, Commit} from '../commit';
30+
import {ConventionalCommit, Commit, parseConventionalCommits} from '../commit';
3131
import {Version, VersionsMap} from '../version';
3232
import {TagName} from '../util/tag-name';
3333
import {Release} from '../release';
@@ -277,15 +277,35 @@ export abstract class BaseStrategy implements Strategy {
277277
draft,
278278
manifestPath,
279279
}: {
280-
commits: ConventionalCommit[];
280+
commits: Commit[];
281281
latestRelease?: Release;
282282
draft?: boolean;
283283
labels?: string[];
284284
existingPullRequest?: PullRequest;
285285
manifestPath?: string;
286286
}): Promise<ReleasePullRequest | undefined> {
287-
const conventionalCommits = await this.postProcessCommits(commits);
288-
this.logger.info(`Considering: ${commits.length} conventional commits`);
287+
this.logger.info(`Considering: ${commits.length} raw commits`);
288+
289+
const mergeCommitRegex =
290+
/^Merge pull request #\d+ from [^/]+\/release-please(--[\w-]+)+$/;
291+
292+
// if there are no commits that are not release pr merge commits, there's nothing to include in a new release PR
293+
if (commits.every(c => mergeCommitRegex.test(c.message))) {
294+
this.logger.info(
295+
`No commits to consider for ${this.path}, all commits are merges of release PRs`
296+
);
297+
return;
298+
}
299+
300+
// do not parse commits if they are already conventional commits
301+
let conventionalCommits =
302+
commits[0] && 'type' in commits[0]
303+
? (commits as ConventionalCommit[])
304+
: parseConventionalCommits(commits, this.logger);
305+
conventionalCommits = await this.postProcessCommits(conventionalCommits);
306+
this.logger.info(
307+
`Considering: ${conventionalCommits.length} conventional commits`
308+
);
289309

290310
const component = await this.getComponent();
291311
this.logger.debug('component:', component);

0 commit comments

Comments
 (0)