Skip to content

Commit

Permalink
Merge pull request #674 from ckeditor/i/8265
Browse files Browse the repository at this point in the history
Fix (env): The `getNewVersionType()` util will return a proper version when generating the changelog for a single package. Closes ckeditor/ckeditor5#8265.

Feature (env): `generateChangelogForSinglePackage()` will accept an optional option: `options.releaseBranch` (which defaults to `master`).
  • Loading branch information
ma2ciek authored Oct 16, 2020
2 parents 67567dc + bd6ab1d commit 9c25333
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getNewVersionType = require( '../utils/getnewversiontype' );
const getCommits = require( '../utils/getcommits' );
const getWriterOptions = require( '../utils/getwriteroptions' );
const { getRepositoryUrl } = require( '../utils/transformcommitutils' );
const transformCommitForSubRepositoryFactory = require( '../utils/transformcommitfactory' );
const transformCommitFactory = require( '../utils/transformcommitfactory' );

const SKIP_GENERATE_CHANGELOG = 'Typed "skip" as a new version. Aborting.';

Expand All @@ -37,6 +37,8 @@ const SKIP_GENERATE_CHANGELOG = 'Typed "skip" as a new version. Aborting.';
*
* @param {Boolean} [options.collaborationFeatures=false] Whether to add a note about collaboration features.
*
* @param {String} [options.releaseBranch='master'] A name of the branch that should be used for releasing packages.
*
* @returns {Promise}
*/
module.exports = function generateChangelogForSinglePackage( options = {} ) {
Expand All @@ -45,12 +47,13 @@ module.exports = function generateChangelogForSinglePackage( options = {} ) {

logProcess( chalk.bold( `Generating changelog for "${ chalk.underline( pkgJson.name ) }"...` ) );

const transformCommit = transformCommitForSubRepositoryFactory();
const transformCommit = transformCommitFactory();

logProcess( 'Collecting all commits since the last release...' );

const commitOptions = {
from: options.from ? options.from : 'v' + pkgJson.version
from: options.from ? options.from : 'v' + pkgJson.version,
releaseBranch: options.releaseBranch
};

// Initial release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function getNewVersionType( commits ) {

for ( const commit of publicCommits ) {
for ( const note of commit.notes ) {
if ( note.title === 'MAJOR BREAKING CHANGES' ) {
if ( note.title === 'MAJOR BREAKING CHANGES' || note.title === 'BREAKING CHANGES' ) {
return 'major';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,41 @@ describe( 'dev-env/release-tools/utils', () => {
expect( getNewVersionType( commits ) ).to.equal( 'major' );
} );

it( 'returns "major" if BREAKING CHANGES was introduced in "type:Other" commit', () => {
const commits = [
{ isPublicCommit: true, notes: [ { title: 'BREAKING CHANGES' } ], rawType: 'Other' }
];
expect( getNewVersionType( commits ) ).to.equal( 'major' );
} );

it( 'returns "major" if MAJOR BREAKING CHANGES was introduced in "type:Fix" commit', () => {
const commits = [
{ isPublicCommit: true, notes: [ { title: 'MAJOR BREAKING CHANGES' } ], rawType: 'Fix' }
];
expect( getNewVersionType( commits ) ).to.equal( 'major' );
} );

it( 'returns "major" if BREAKING CHANGES was introduced in "type:Fix" commit', () => {
const commits = [
{ isPublicCommit: true, notes: [ { title: 'BREAKING CHANGES' } ], rawType: 'Fix' }
];
expect( getNewVersionType( commits ) ).to.equal( 'major' );
} );

it( 'returns "major" if MAJOR BREAKING CHANGES was introduced in "type:Feature" commit', () => {
const commits = [
{ isPublicCommit: true, notes: [ { title: 'MAJOR BREAKING CHANGES' } ], rawType: 'Feature' }
];
expect( getNewVersionType( commits ) ).to.equal( 'major' );
} );

it( 'returns "major" if BREAKING CHANGES was introduced in "type:Feature" commit', () => {
const commits = [
{ isPublicCommit: true, notes: [ { title: 'BREAKING CHANGES' } ], rawType: 'Feature' }
];
expect( getNewVersionType( commits ) ).to.equal( 'major' );
} );

it( 'returns "minor" if MINOR BREAKING CHANGES was introduced in "type:Other" commit', () => {
const commits = [
{ isPublicCommit: true, notes: [ { title: 'MINOR BREAKING CHANGES' } ], rawType: 'Other' }
Expand Down

0 comments on commit 9c25333

Please sign in to comment.