Skip to content

Commit 089239f

Browse files
authored
fix: ruby should use pre-release seperator (#201)
1 parent 4090374 commit 089239f

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

__snapshots__/version-rb.ts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ exports['version.rb updateContent updates prerelease versions in version.rb 1']
6767
module Google
6868
module Cloud
6969
module Bigtable
70-
VERSION = "10.0.0-alpha1".freeze
70+
VERSION = "10.0.0.pre.alpha1".freeze
7171
end
7272
end
7373
end

src/updaters/ruby/common.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ export const RUBY_VERSION_REGEX = /((\d+).(\d)+.(\d+)(.\w+.*)?)/g;
2828
*/
2929
export function stringifyRubyVersion(
3030
version: Version,
31-
useDotPrePreleaseSeperator = false
31+
useDotPrePreleaseSeperator = true
3232
) {
3333
if (!useDotPrePreleaseSeperator) {
3434
return version.toString();
3535
}
3636

3737
return `${version.major}.${version.minor}.${version.patch}${
38-
version.preRelease ? `.${version.preRelease}` : ''
38+
version.preRelease
39+
? `.pre.${version.preRelease.replace(/^[.-]|[.-]$/g, '')}`
40+
: ''
3941
}`;
4042
}
4143

test/updaters/ruby/common.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ describe('ruby-common', () => {
4848
['1.2.3', '1.2.3'],
4949
['1.2.10', '1.2.10'],
5050
['15.10.22', '15.10.22'],
51-
['1.0.0-alpha', '1.0.0-alpha'],
52-
['1.0.0-alpha1', '1.0.0-alpha1'],
53-
['2.0.0-rc1', '2.0.0-rc1'],
51+
['1.0.0-alpha', '1.0.0.pre.alpha'],
52+
['1.0.0-alpha1', '1.0.0.pre.alpha1'],
53+
['2.0.0-rc1', '2.0.0.pre.rc1'],
5454
];
5555

5656
testTable.forEach(([input, expected]) => {
@@ -87,10 +87,10 @@ describe('ruby-common', () => {
8787
['1.2.3', '1.2.3'],
8888
['1.2.10', '1.2.10'],
8989
['15.10.22', '15.10.22'],
90-
['1.0.0-alpha', '1.0.0.alpha'],
91-
['1.0.0-alpha1', '1.0.0.alpha1'],
92-
['2.0.0-beta', '2.0.0.beta'],
93-
['2.0.0-rc1', '2.0.0.rc1'],
90+
['1.0.0-alpha', '1.0.0.pre.alpha'],
91+
['1.0.0-alpha1', '1.0.0.pre.alpha1'],
92+
['2.0.0-beta', '2.0.0.pre.beta'],
93+
['2.0.0-rc1', '2.0.0.pre.rc1'],
9494
];
9595

9696
testTable.forEach(([input, expected]) => {

test/updaters/version-rb.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import {expect} from 'chai';
1516
import {readFileSync} from 'fs';
16-
import {resolve} from 'path';
17-
import snapshot = require('snap-shot-it');
1817
import {describe, it} from 'mocha';
19-
import {expect} from 'chai';
18+
import {resolve} from 'path';
2019
import {VersionRB} from '../../src/updaters/ruby/version-rb';
2120
import {Version} from '../../src/version';
21+
import snapshot = require('snap-shot-it');
2222

2323
const fixturesPath = './test/updaters/fixtures';
2424

@@ -31,8 +31,14 @@ describe('version.rb', () => {
3131
['0.2.0', '"0.1.0"', '"0.2.0"', true, 'minor'],
3232
['0.2.1', '"0.2.0"', '"0.2.1"', true, 'patch'],
3333
['0.2.11', '"0.2.10"', '"0.2.11"', true, 'long patch'],
34-
['1.0.0-alpha1', '"0.9.0"', '"1.0.0-alpha1"', true, 'prerelease'],
35-
['1.0.0-beta', '"1.0.0-alpha1"', '"1.0.0-beta"', true, 'prerelease bump'],
34+
['1.0.0-alpha1', '"0.9.0"', '"1.0.0.pre.alpha1"', true, 'prerelease'],
35+
[
36+
'1.0.0-beta',
37+
'"1.0.0-alpha1"',
38+
'"1.0.0.pre.beta"',
39+
true,
40+
'prerelease bump',
41+
],
3642
['1.0.0', '"1.0.0.beta"', '"1.0.0"', true, 'major'],
3743
['1.0.1', '"1.0.0"', '"1.0.1"', true, 'major patch'],
3844
['1.0.0', '"1.0"', '"1.0"', false, 'ignored'],

0 commit comments

Comments
 (0)