Skip to content

Commit 558331c

Browse files
authored
fix(java): snapshots should bump versionsMap versions (#1386)
Files were not being updated because the `versionsMap` was not version bumping the component versions Fixes #1381
1 parent f6b3202 commit 558331c

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

src/strategies/base.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,17 +355,11 @@ export abstract class BaseStrategy implements Strategy {
355355
conventionalCommits: ConventionalCommit[],
356356
_newVersion: Version
357357
): Promise<VersionsMap> {
358-
for (const versionKey of versionsMap.keys()) {
359-
const version = versionsMap.get(versionKey);
360-
if (!version) {
361-
logger.warn(`didn't find version for ${versionKey}`);
362-
continue;
363-
}
364-
const newVersion = await this.versioningStrategy.bump(
365-
version,
366-
conventionalCommits
358+
for (const [component, version] of versionsMap.entries()) {
359+
versionsMap.set(
360+
component,
361+
await this.versioningStrategy.bump(version, conventionalCommits)
367362
);
368-
versionsMap.set(versionKey, newVersion);
369363
}
370364
return versionsMap;
371365
}

src/strategies/java.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export class Java extends BaseStrategy {
107107
? await this.snapshotVersioning.bump(latestRelease.tag.version, [])
108108
: this.initialReleaseVersion();
109109
const versionsMap = await this.buildVersionsMap([]);
110+
for (const [component, version] of versionsMap.entries()) {
111+
versionsMap.set(
112+
component,
113+
await this.snapshotVersioning.bump(version, [])
114+
);
115+
}
110116
const pullRequestTitle = PullRequestTitle.ofComponentTargetBranchVersion(
111117
component || '',
112118
this.targetBranch,

test/strategies/java-yoshi.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,11 @@ describe('JavaYoshi', () => {
235235
const updates = release!.updates;
236236
assertHasUpdate(updates, 'CHANGELOG.md', Changelog);
237237
const {updater} = assertHasUpdate(updates, 'path1/pom.xml', JavaUpdate);
238-
expect((updater as JavaUpdate).isSnapshot).to.be.false;
238+
const javaUpdater = updater as JavaUpdate;
239+
expect(javaUpdater.isSnapshot).to.be.false;
240+
expect(
241+
javaUpdater.versionsMap?.get('google-cloud-trace')?.toString()
242+
).to.eql('0.108.1-beta');
239243
assertHasUpdate(updates, 'path2/pom.xml', JavaUpdate);
240244
assertHasUpdate(updates, 'path1/build.gradle', JavaUpdate);
241245
assertHasUpdate(updates, 'path1/build.gradle', JavaUpdate);
@@ -303,7 +307,11 @@ describe('JavaYoshi', () => {
303307
const updates = release!.updates;
304308
assertNoHasUpdate(updates, 'CHANGELOG.md');
305309
const {updater} = assertHasUpdate(updates, 'path1/pom.xml', JavaUpdate);
306-
expect((updater as JavaUpdate).isSnapshot).to.be.true;
310+
const javaUpdater = updater as JavaUpdate;
311+
expect(javaUpdater.isSnapshot).to.be.true;
312+
expect(
313+
javaUpdater.versionsMap?.get('google-cloud-trace')?.toString()
314+
).to.eql('0.108.1-beta-SNAPSHOT');
307315
assertHasUpdate(updates, 'path2/pom.xml', JavaUpdate);
308316
assertHasUpdate(updates, 'path1/build.gradle', JavaUpdate);
309317
assertHasUpdate(updates, 'path1/build.gradle', JavaUpdate);

0 commit comments

Comments
 (0)