From 57c76e1ec73bfec00259e8ad112751661a341f7f Mon Sep 17 00:00:00 2001 From: meorphis Date: Mon, 10 Feb 2025 05:50:58 -0500 Subject: [PATCH] improvements for ruby version updates --- src/strategies/ruby.ts | 23 ++++++++++++++++++++++- test/strategies/ruby.ts | 16 ++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/strategies/ruby.ts b/src/strategies/ruby.ts index 9b3581060..13dff0072 100644 --- a/src/strategies/ruby.ts +++ b/src/strategies/ruby.ts @@ -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, @@ -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] || + '', }), }); diff --git a/test/strategies/ruby.ts b/test/strategies/ruby.ts index ad7f70966..066a0a34e 100644 --- a/test/strategies/ruby.ts +++ b/test/strategies/ruby.ts @@ -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 () => { @@ -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