Skip to content

Commit a610dd9

Browse files
author
meorphis
committed
Revert "do not leave comment if custom version has not been set (#212)"
This reverts commit e163d6f.
1 parent 5a068dc commit a610dd9

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed

src/strategies/base.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
MANIFEST_PULL_REQUEST_TITLE_PATTERN,
2323
ExtraFile,
2424
DEFAULT_CUSTOM_VERSION_LABEL,
25+
DEFAULT_RELEASE_PLEASE_MANIFEST,
2526
} from '../manifest';
2627
import {DefaultVersioningStrategy} from '../versioning-strategies/default';
2728
import {DefaultChangelogNotes} from '../changelog-notes/default';
@@ -274,12 +275,14 @@ export abstract class BaseStrategy implements Strategy {
274275
labels = [],
275276
latestRelease,
276277
draft,
278+
manifestPath,
277279
}: {
278280
commits: Commit[];
279281
latestRelease?: Release;
280282
draft?: boolean;
281283
labels?: string[];
282284
existingPullRequest?: PullRequest;
285+
manifestPath?: string;
283286
}): Promise<ReleasePullRequest | undefined> {
284287
this.logger.info(`Considering: ${commits.length} raw commits`);
285288

@@ -388,7 +391,13 @@ To set a custom version be sure to use the [semantic versioning format](https://
388391
} else {
389392
// look at the manifest from release branch and compare against version from PR title
390393
try {
391-
if (newVersion.toString() !== existingPRTitleVersion.toString()) {
394+
const manifest =
395+
(await this.github.getFileJson<Record<string, string>>(
396+
manifestPath || DEFAULT_RELEASE_PLEASE_MANIFEST,
397+
existingPullRequest.headBranchName
398+
)) || {};
399+
const componentVersion = manifest[component || '.'];
400+
if (componentVersion !== existingPRTitleVersion?.toString()) {
392401
// version from title has been edited, add custom version label, a comment, and use the title version
393402
this.github.addIssueLabels(
394403
[DEFAULT_CUSTOM_VERSION_LABEL],

src/strategies/java.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ export class Java extends BaseStrategy {
7979
labels = [],
8080
latestRelease,
8181
draft,
82+
manifestPath,
8283
}: {
8384
commits: ConventionalCommit[];
8485
latestRelease?: Release;
8586
draft?: boolean;
8687
labels?: string[];
8788
existingPullRequest?: PullRequest;
89+
manifestPath?: string;
8890
}): Promise<ReleasePullRequest | undefined> {
8991
if (await this.needsSnapshot(commits, latestRelease)) {
9092
this.logger.info('Repository needs a snapshot bump.');
@@ -100,6 +102,7 @@ export class Java extends BaseStrategy {
100102
latestRelease,
101103
draft,
102104
labels,
105+
manifestPath,
103106
});
104107
}
105108

test/manifest.ts

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,13 +2494,67 @@ describe('Manifest', () => {
24942494
})
24952495
)
24962496
)
2497+
.withArgs(
2498+
'.release-please-manifest.json',
2499+
'release-please--branches--main--changes--next--components--pkg1'
2500+
)
2501+
.resolves(
2502+
buildGitHubFileRaw(
2503+
JSON.stringify({
2504+
'path/a': '1.0.1',
2505+
})
2506+
)
2507+
)
2508+
.withArgs(
2509+
'.release-please-manifest.json',
2510+
'release-please--branches--main--changes--next--components--pkg2'
2511+
)
2512+
.resolves(
2513+
buildGitHubFileRaw(
2514+
JSON.stringify({
2515+
'path/b': '2.0.1',
2516+
})
2517+
)
2518+
)
24972519
.withArgs('path/b/package.json', 'next')
24982520
.resolves(
24992521
buildGitHubFileRaw(
25002522
JSON.stringify({
25012523
name: 'pkg2',
25022524
})
25032525
)
2526+
)
2527+
.withArgs(
2528+
'.release-please-manifest.json',
2529+
'release-please--branches--main--changes--next--components--pkg3'
2530+
)
2531+
.resolves(
2532+
buildGitHubFileRaw(
2533+
JSON.stringify({
2534+
'path/c': '3.0.1',
2535+
})
2536+
)
2537+
)
2538+
.withArgs('path/c/setup.py', 'next')
2539+
.resolves(
2540+
buildGitHubFileRaw(
2541+
`
2542+
name = "pkg3"
2543+
description = "Something"
2544+
version = "3.0.0"
2545+
`
2546+
)
2547+
)
2548+
.withArgs(
2549+
'.release-please-manifest.json',
2550+
'release-please--branches--main--changes--next--components--pkg4'
2551+
)
2552+
.resolves(
2553+
buildGitHubFileRaw(
2554+
JSON.stringify({
2555+
'path/d': '4.0.1',
2556+
})
2557+
)
25042558
);
25052559

25062560
const findFilesByFilenameAndRefStub = sandbox
@@ -2535,7 +2589,7 @@ describe('Manifest', () => {
25352589
const pullRequests = await manifest.buildPullRequests(
25362590
[
25372591
{
2538-
title: 'chore(main): release v6.7.9-alpha.1', // version from title differs from expected 4.0.1
2592+
title: 'chore(main): release v6.7.9-alpha.1', // version from title differs from PR manifest
25392593
body: 'some content',
25402594
headBranchName:
25412595
'release-please--branches--main--changes--next--components--pkg1',
@@ -2545,7 +2599,7 @@ describe('Manifest', () => {
25452599
files: [],
25462600
},
25472601
{
2548-
title: 'chore(main): release v7.8.9', // version from title differs from expected 4.0.1
2602+
title: 'chore(main): release v7.8.9', // version from title differs from PR manifest
25492603
body: 'some content',
25502604
headBranchName:
25512605
'release-please--branches--main--changes--next--components--pkg2',
@@ -2555,7 +2609,7 @@ describe('Manifest', () => {
25552609
files: [],
25562610
},
25572611
{
2558-
title: 'chore(main): release 8.9.0', // version from title differs from expected 4.0.1
2612+
title: 'chore(main): release 8.9.0', // version from title differs from PR manifest
25592613
body: 'some content',
25602614
headBranchName:
25612615
'release-please--branches--main--changes--next--components--pkg3',
@@ -2565,7 +2619,7 @@ describe('Manifest', () => {
25652619
files: [],
25662620
},
25672621
{
2568-
title: 'chore(main): release v9.0.1', // version from title differs from expected 4.0.1
2622+
title: 'chore(main): release v9.0.1', // version from title differs from PR manifest
25692623
body: 'some content',
25702624
headBranchName:
25712625
'release-please--branches--main--changes--next--components--pkg4',
@@ -2582,9 +2636,9 @@ describe('Manifest', () => {
25822636
expect(pullRequests[1].version?.toString()).to.eql('7.8.9');
25832637
expect(pullRequests[2].version?.toString()).to.eql('8.9.0');
25842638
expect(pullRequests[3].version?.toString()).to.eql('9.0.1');
2639+
sinon.assert.called(getFileContentsOnBranchStub);
25852640
sinon.assert.called(addIssueLabelsStub);
25862641
sinon.assert.called(findFilesByFilenameAndRefStub);
2587-
sinon.assert.called(getFileContentsOnBranchStub);
25882642
expect(commentCount).to.eql(4);
25892643
});
25902644

0 commit comments

Comments
 (0)