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

improvements for ruby version updates #193

Merged
merged 2 commits into from
Feb 10, 2025
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
23 changes: 22 additions & 1 deletion src/strategies/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class Ruby extends BaseStrategy {
const versionFile: string = this.versionFile
? this.versionFile
: `lib/${(this.component || '').replace(/-/g, '/')}/version.rb`;

updates.push({
path: this.addPath(versionFile),
createIfMissing: false,
Expand All @@ -58,12 +59,32 @@ export class Ruby extends BaseStrategy {
}),
});

updates.push({
path: `rbi/${versionFile}i`,
createIfMissing: false,
updater: new VersionRB({
version,
}),
});

updates.push({
path: `sig/${versionFile}s`,
createIfMissing: false,
updater: new VersionRB({
version,
}),
});

updates.push({
path: this.addPath('Gemfile.lock'),
createIfMissing: false,
updater: new GemfileLock({
version,
gemName: this.component || '',
gemName:
this.component ||
// grab the gem name from the version file path if it's not provided via the component
this.versionFile.match(/lib\/(.*)\/version.rb/)?.[1] ||
'',
}),
});

Expand Down
16 changes: 14 additions & 2 deletions test/strategies/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,19 @@ describe('Ruby', () => {
latestRelease,
});
const updates = release!.updates;
expect(updates).lengthOf(3);
expect(updates).lengthOf(5);
assertHasUpdate(updates, 'CHANGELOG.md', Changelog);
assertHasUpdate(updates, 'lib/google/cloud/automl/version.rb', VersionRB);
assertHasUpdate(
updates,
'sig/lib/google/cloud/automl/version.rbs',
VersionRB
);
assertHasUpdate(
updates,
'rbi/lib/google/cloud/automl/version.rbi',
VersionRB
);
assertHasUpdate(updates, 'Gemfile.lock', GemfileLock);
});
it('allows overriding version file', async () => {
Expand All @@ -115,9 +125,11 @@ describe('Ruby', () => {
latestRelease,
});
const updates = release!.updates;
expect(updates).lengthOf(3);
expect(updates).lengthOf(5);
assertHasUpdate(updates, 'CHANGELOG.md', Changelog);
assertHasUpdate(updates, 'lib/foo/version.rb', VersionRB);
assertHasUpdate(updates, 'sig/lib/foo/version.rbs', VersionRB);
assertHasUpdate(updates, 'rbi/lib/foo/version.rbi', VersionRB);
assertHasUpdate(updates, 'Gemfile.lock', GemfileLock);
});
// TODO: add tests for tag separator
Expand Down
Loading