Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add always-bump-minor versioning strategy (#1744)
feat: add always-bump-major versioning strategy
- Loading branch information
Showing
7 changed files
with
356 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {Version} from '../version'; | ||
import {ConventionalCommit} from '../commit'; | ||
import {DefaultVersioningStrategy} from './default'; | ||
import {VersionUpdater, MajorVersionUpdate} from '../versioning-strategy'; | ||
|
||
/** | ||
* This VersioningStrategy always bumps the major version. | ||
*/ | ||
export class AlwaysBumpMajor extends DefaultVersioningStrategy { | ||
determineReleaseType( | ||
_version: Version, | ||
_commits: ConventionalCommit[] | ||
): VersionUpdater { | ||
return new MajorVersionUpdate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {Version} from '../version'; | ||
import {ConventionalCommit} from '../commit'; | ||
import {DefaultVersioningStrategy} from './default'; | ||
import {VersionUpdater, MinorVersionUpdate} from '../versioning-strategy'; | ||
|
||
/** | ||
* This VersioningStrategy always bumps the minor version. | ||
*/ | ||
export class AlwaysBumpMinor extends DefaultVersioningStrategy { | ||
determineReleaseType( | ||
_version: Version, | ||
_commits: ConventionalCommit[] | ||
): VersionUpdater { | ||
return new MinorVersionUpdate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {describe, it} from 'mocha'; | ||
|
||
import {expect} from 'chai'; | ||
import {AlwaysBumpMajor} from '../../src/versioning-strategies/always-bump-major'; | ||
import {Version} from '../../src/version'; | ||
|
||
describe('MajorVersioningStrategy', () => { | ||
describe('with breaking change', () => { | ||
const commits = [ | ||
{ | ||
sha: 'sha1', | ||
message: 'feat: some feature', | ||
files: ['path1/file1.txt'], | ||
type: 'feat', | ||
scope: null, | ||
bareMessage: 'some feature', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
{ | ||
sha: 'sha2', | ||
message: 'fix!: some bugfix', | ||
files: ['path1/file1.rb'], | ||
type: 'fix', | ||
scope: null, | ||
bareMessage: 'some bugfix', | ||
notes: [{title: 'BREAKING CHANGE', text: 'some bugfix'}], | ||
references: [], | ||
breaking: true, | ||
}, | ||
{ | ||
sha: 'sha3', | ||
message: 'docs: some documentation', | ||
files: ['path1/file1.java'], | ||
type: 'docs', | ||
scope: null, | ||
bareMessage: 'some documentation', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
]; | ||
it('bumps major', async () => { | ||
const strategy = new AlwaysBumpMajor(); | ||
const oldVersion = Version.parse('1.2.3'); | ||
const newVersion = await strategy.bump(oldVersion, commits); | ||
expect(newVersion.toString()).to.equal('2.0.0'); | ||
}); | ||
}); | ||
|
||
describe('with a feature', () => { | ||
const commits = [ | ||
{ | ||
sha: 'sha1', | ||
message: 'feat: some feature', | ||
files: ['path1/file1.txt'], | ||
type: 'feat', | ||
scope: null, | ||
bareMessage: 'some feature', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
{ | ||
sha: 'sha2', | ||
message: 'fix: some bugfix', | ||
files: ['path1/file1.rb'], | ||
type: 'fix', | ||
scope: null, | ||
bareMessage: 'some bugfix', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
{ | ||
sha: 'sha3', | ||
message: 'docs: some documentation', | ||
files: ['path1/file1.java'], | ||
type: 'docs', | ||
scope: null, | ||
bareMessage: 'some documentation', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
]; | ||
it('bumps major for minor', async () => { | ||
const strategy = new AlwaysBumpMajor(); | ||
const oldVersion = Version.parse('1.2.3'); | ||
const newVersion = await strategy.bump(oldVersion, commits); | ||
expect(newVersion.toString()).to.equal('2.0.0'); | ||
}); | ||
}); | ||
|
||
describe('with a fix', () => { | ||
const commits = [ | ||
{ | ||
sha: 'sha2', | ||
message: 'fix: some bugfix', | ||
files: ['path1/file1.rb'], | ||
type: 'fix', | ||
scope: null, | ||
bareMessage: 'some bugfix', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
{ | ||
sha: 'sha3', | ||
message: 'docs: some documentation', | ||
files: ['path1/file1.java'], | ||
type: 'docs', | ||
scope: null, | ||
bareMessage: 'some documentation', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
]; | ||
it('bumps major for patch', async () => { | ||
const strategy = new AlwaysBumpMajor(); | ||
const oldVersion = Version.parse('1.2.3'); | ||
const newVersion = await strategy.bump(oldVersion, commits); | ||
expect(newVersion.toString()).to.equal('2.0.0'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {describe, it} from 'mocha'; | ||
|
||
import {expect} from 'chai'; | ||
import {AlwaysBumpMinor} from '../../src/versioning-strategies/always-bump-minor'; | ||
import {Version} from '../../src/version'; | ||
|
||
describe('MinorVersioningStrategy', () => { | ||
describe('with breaking change', () => { | ||
const commits = [ | ||
{ | ||
sha: 'sha1', | ||
message: 'feat: some feature', | ||
files: ['path1/file1.txt'], | ||
type: 'feat', | ||
scope: null, | ||
bareMessage: 'some feature', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
{ | ||
sha: 'sha2', | ||
message: 'fix!: some bugfix', | ||
files: ['path1/file1.rb'], | ||
type: 'fix', | ||
scope: null, | ||
bareMessage: 'some bugfix', | ||
notes: [{title: 'BREAKING CHANGE', text: 'some bugfix'}], | ||
references: [], | ||
breaking: true, | ||
}, | ||
{ | ||
sha: 'sha3', | ||
message: 'docs: some documentation', | ||
files: ['path1/file1.java'], | ||
type: 'docs', | ||
scope: null, | ||
bareMessage: 'some documentation', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
]; | ||
it('bumps minor for major', async () => { | ||
const strategy = new AlwaysBumpMinor(); | ||
const oldVersion = Version.parse('1.2.3'); | ||
const newVersion = await strategy.bump(oldVersion, commits); | ||
expect(newVersion.toString()).to.equal('1.3.0'); | ||
}); | ||
}); | ||
|
||
describe('with a feature', () => { | ||
const commits = [ | ||
{ | ||
sha: 'sha1', | ||
message: 'feat: some feature', | ||
files: ['path1/file1.txt'], | ||
type: 'feat', | ||
scope: null, | ||
bareMessage: 'some feature', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
{ | ||
sha: 'sha2', | ||
message: 'fix: some bugfix', | ||
files: ['path1/file1.rb'], | ||
type: 'fix', | ||
scope: null, | ||
bareMessage: 'some bugfix', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
{ | ||
sha: 'sha3', | ||
message: 'docs: some documentation', | ||
files: ['path1/file1.java'], | ||
type: 'docs', | ||
scope: null, | ||
bareMessage: 'some documentation', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
]; | ||
it('bumps minor', async () => { | ||
const strategy = new AlwaysBumpMinor(); | ||
const oldVersion = Version.parse('1.2.3'); | ||
const newVersion = await strategy.bump(oldVersion, commits); | ||
expect(newVersion.toString()).to.equal('1.3.0'); | ||
}); | ||
}); | ||
|
||
describe('with a fix', () => { | ||
const commits = [ | ||
{ | ||
sha: 'sha2', | ||
message: 'fix: some bugfix', | ||
files: ['path1/file1.rb'], | ||
type: 'fix', | ||
scope: null, | ||
bareMessage: 'some bugfix', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
{ | ||
sha: 'sha3', | ||
message: 'docs: some documentation', | ||
files: ['path1/file1.java'], | ||
type: 'docs', | ||
scope: null, | ||
bareMessage: 'some documentation', | ||
notes: [], | ||
references: [], | ||
breaking: false, | ||
}, | ||
]; | ||
it('bumps minor for patch', async () => { | ||
const strategy = new AlwaysBumpMinor(); | ||
const oldVersion = Version.parse('1.2.3'); | ||
const newVersion = await strategy.bump(oldVersion, commits); | ||
expect(newVersion.toString()).to.equal('1.3.0'); | ||
}); | ||
}); | ||
}); |