Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java-yoshi): match full artifact id when updating versions #2398

Merged
merged 8 commits into from
Oct 8, 2024
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
16 changes: 16 additions & 0 deletions __snapshots__/version-manifest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
exports['VersionManifest updateContent updates versions.txt with an artifact id is another ones suffix with snapshot 1'] = `
# Format:
# module:released-version:current-version

google-cloud-admin:2.3.4:2.3.4
admin:3.4.5:3.4.5
`

exports['VersionManifest updateContent updates versions.txt with an artifact id is another ones suffix without snapshot 1'] = `
# Format:
# module:released-version:current-version

google-cloud-admin:2.3.6:2.3.6
admin:3.4.3:3.4.3
`

exports['VersionManifest updateContent updates versions.txt with snapshot released version 1'] = `
# Format:
# module:released-version:current-version
Expand Down
4 changes: 2 additions & 2 deletions src/updaters/java/versions-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ export class VersionsManifest extends JavaUpdate {
if (version.includes('SNAPSHOT')) {
newLines.push(
line.replace(
new RegExp(`${packageName}:(.*):(.*)`, 'g'),
new RegExp(`^${packageName}:(.*):(.*)`, 'g'),
`${packageName}:$1:${version}`
)
);
} else {
newLines.push(
line.replace(
new RegExp(`${packageName}:(.*):(.*)`, 'g'),
new RegExp(`^${packageName}:(.*):(.*)`, 'g'),
`${packageName}:${version}:${version}`
)
);
Expand Down
5 changes: 5 additions & 0 deletions test/updaters/fixtures/versions-suffix-with-snapshot.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Format:
# module:released-version:current-version

google-cloud-admin:2.3.5:2.3.5
admin:3.4.2:3.4.2
5 changes: 5 additions & 0 deletions test/updaters/fixtures/versions-suffix-without-snapshot.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Format:
# module:released-version:current-version

google-cloud-admin:2.3.0:2.3.1-SNAPSHOT
admin:3.4.0:3.4.1-SNAPSHOT
32 changes: 32 additions & 0 deletions test/updaters/version-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,37 @@ describe('VersionManifest', () => {
const newContent = javaAuthVersions.updateContent(oldContent);
snapshot(newContent);
});

it('updates versions.txt with an artifact id is another ones suffix with snapshot', async () => {
const oldContent = readFileSync(
resolve(fixturesPath, './versions-suffix-with-snapshot.txt'),
'utf8'
).replace(/\r\n/g, '\n');
const versions = new Map<string, Version>();
versions.set('google-cloud-admin', Version.parse('2.3.4'));
versions.set('admin', Version.parse('3.4.5'));
const javaAuthVersions = new VersionsManifest({
versionsMap: versions,
version: Version.parse('1.2.3'),
});
const newContent = javaAuthVersions.updateContent(oldContent);
snapshot(newContent);
});

it('updates versions.txt with an artifact id is another ones suffix without snapshot', async () => {
const oldContent = readFileSync(
resolve(fixturesPath, './versions-suffix-without-snapshot.txt'),
'utf8'
).replace(/\r\n/g, '\n');
const versions = new Map<string, Version>();
versions.set('google-cloud-admin', Version.parse('2.3.6'));
versions.set('admin', Version.parse('3.4.3'));
const javaAuthVersions = new VersionsManifest({
versionsMap: versions,
version: Version.parse('1.2.3'),
});
const newContent = javaAuthVersions.updateContent(oldContent);
snapshot(newContent);
});
});
});
Loading