Skip to content

Commit e163d6f

Browse files
meorphismeorphis
andauthored
do not leave comment if custom version has not been set (#212)
* do not leave comment if custom version has not been set * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: meorphis <[email protected]>
1 parent cc3e130 commit e163d6f

File tree

3 files changed

+6
-72
lines changed

3 files changed

+6
-72
lines changed

src/strategies/base.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
MANIFEST_PULL_REQUEST_TITLE_PATTERN,
2323
ExtraFile,
2424
DEFAULT_CUSTOM_VERSION_LABEL,
25-
DEFAULT_RELEASE_PLEASE_MANIFEST,
2625
} from '../manifest';
2726
import {DefaultVersioningStrategy} from '../versioning-strategies/default';
2827
import {DefaultChangelogNotes} from '../changelog-notes/default';
@@ -275,14 +274,12 @@ export abstract class BaseStrategy implements Strategy {
275274
labels = [],
276275
latestRelease,
277276
draft,
278-
manifestPath,
279277
}: {
280278
commits: Commit[];
281279
latestRelease?: Release;
282280
draft?: boolean;
283281
labels?: string[];
284282
existingPullRequest?: PullRequest;
285-
manifestPath?: string;
286283
}): Promise<ReleasePullRequest | undefined> {
287284
this.logger.info(`Considering: ${commits.length} raw commits`);
288285

@@ -391,13 +388,7 @@ To set a custom version be sure to use the [semantic versioning format](https://
391388
} else {
392389
// look at the manifest from release branch and compare against version from PR title
393390
try {
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()) {
391+
if (newVersion.toString() !== existingPRTitleVersion.toString()) {
401392
// version from title has been edited, add custom version label, a comment, and use the title version
402393
this.github.addIssueLabels(
403394
[DEFAULT_CUSTOM_VERSION_LABEL],

src/strategies/java.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,12 @@ export class Java extends BaseStrategy {
7979
labels = [],
8080
latestRelease,
8181
draft,
82-
manifestPath,
8382
}: {
8483
commits: ConventionalCommit[];
8584
latestRelease?: Release;
8685
draft?: boolean;
8786
labels?: string[];
8887
existingPullRequest?: PullRequest;
89-
manifestPath?: string;
9088
}): Promise<ReleasePullRequest | undefined> {
9189
if (await this.needsSnapshot(commits, latestRelease)) {
9290
this.logger.info('Repository needs a snapshot bump.');
@@ -102,7 +100,6 @@ export class Java extends BaseStrategy {
102100
latestRelease,
103101
draft,
104102
labels,
105-
manifestPath,
106103
});
107104
}
108105

test/manifest.ts

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,67 +2494,13 @@ 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-
)
25192497
.withArgs('path/b/package.json', 'next')
25202498
.resolves(
25212499
buildGitHubFileRaw(
25222500
JSON.stringify({
25232501
name: 'pkg2',
25242502
})
25252503
)
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-
)
25582504
);
25592505

25602506
const findFilesByFilenameAndRefStub = sandbox
@@ -2589,7 +2535,7 @@ version = "3.0.0"
25892535
const pullRequests = await manifest.buildPullRequests(
25902536
[
25912537
{
2592-
title: 'chore(main): release v6.7.9-alpha.1', // version from title differs from PR manifest
2538+
title: 'chore(main): release v6.7.9-alpha.1', // version from title differs from expected 4.0.1
25932539
body: 'some content',
25942540
headBranchName:
25952541
'release-please--branches--main--changes--next--components--pkg1',
@@ -2599,7 +2545,7 @@ version = "3.0.0"
25992545
files: [],
26002546
},
26012547
{
2602-
title: 'chore(main): release v7.8.9', // version from title differs from PR manifest
2548+
title: 'chore(main): release v7.8.9', // version from title differs from expected 4.0.1
26032549
body: 'some content',
26042550
headBranchName:
26052551
'release-please--branches--main--changes--next--components--pkg2',
@@ -2609,7 +2555,7 @@ version = "3.0.0"
26092555
files: [],
26102556
},
26112557
{
2612-
title: 'chore(main): release 8.9.0', // version from title differs from PR manifest
2558+
title: 'chore(main): release 8.9.0', // version from title differs from expected 4.0.1
26132559
body: 'some content',
26142560
headBranchName:
26152561
'release-please--branches--main--changes--next--components--pkg3',
@@ -2619,7 +2565,7 @@ version = "3.0.0"
26192565
files: [],
26202566
},
26212567
{
2622-
title: 'chore(main): release v9.0.1', // version from title differs from PR manifest
2568+
title: 'chore(main): release v9.0.1', // version from title differs from expected 4.0.1
26232569
body: 'some content',
26242570
headBranchName:
26252571
'release-please--branches--main--changes--next--components--pkg4',
@@ -2636,9 +2582,9 @@ version = "3.0.0"
26362582
expect(pullRequests[1].version?.toString()).to.eql('7.8.9');
26372583
expect(pullRequests[2].version?.toString()).to.eql('8.9.0');
26382584
expect(pullRequests[3].version?.toString()).to.eql('9.0.1');
2639-
sinon.assert.called(getFileContentsOnBranchStub);
26402585
sinon.assert.called(addIssueLabelsStub);
26412586
sinon.assert.called(findFilesByFilenameAndRefStub);
2587+
sinon.assert.called(getFileContentsOnBranchStub);
26422588
expect(commentCount).to.eql(4);
26432589
});
26442590

0 commit comments

Comments
 (0)