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 3 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
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"chai": "^4.2.0",
"config-chain": "^1.1.13",
"cross-env": "^7.0.0",
"gts": "^3.1.0",
"gts": "^3.1.1",
"mocha": "^9.2.2",
"nock": "^13.0.0",
"sinon": "18.0.1",
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-prefix.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.4:2.3.4
admin:3.4.5:3.4.5
18 changes: 18 additions & 0 deletions test/updaters/version-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,22 @@
snapshot(newContent);
});
});

describe('updateContent', () => {
it('updates versions.txt with a version prefix', async () => {
const oldContent = readFileSync(
resolve(fixturesPath, './versions-prefix.txt'),

Check failure on line 90 in test/updaters/version-manifest.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
'utf8'

Check failure on line 91 in test/updaters/version-manifest.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
).replace(/\r\n/g, '\n');
const versions = new Map<string, Version>();
versions.set('google-cloud-trace', Version.parse('2.3.4'));
versions.set('trace', Version.parse('3.4.5'));
const javaAuthVersions = new VersionsManifest({
versionsMap: versions,
version: Version.parse('1.2.3'),
});
const newContent = javaAuthVersions.updateContent(oldContent);
snapshot(newContent);
});
});
});
Loading