From f3ad821ac3e81eb441b9a9fefbcb65d9604bd0dd Mon Sep 17 00:00:00 2001 From: Marcin Panek Date: Tue, 22 Oct 2024 15:35:18 +0200 Subject: [PATCH 1/2] Added skip ci to the `commitAndTag()` function. --- .../lib/tasks/commitandtag.js | 5 +++-- .../tests/tasks/commitandtag.js | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js b/packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js index 427f0ff5d..0d7b07e2e 100644 --- a/packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js +++ b/packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js @@ -16,9 +16,10 @@ const { toUnix } = upath; * @param {string} options.version The commit will contain this param in its message and the tag will have a `v` prefix. * @param {Array.} options.files Array of glob patterns for files to be added to the release commit. * @param {string} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved. + * @param {boolean} [options.skipCi=true] Whether to add [skip ci] to the commit. * @returns {Promise} */ -export default async function commitAndTag( { version, files, cwd = process.cwd() } ) { +export default async function commitAndTag( { version, files, cwd = process.cwd(), skipCi = true } ) { const normalizedCwd = toUnix( cwd ); const filePathsToAdd = await glob( files, { cwd: normalizedCwd, absolute: true, nodir: true } ); @@ -38,6 +39,6 @@ export default async function commitAndTag( { version, files, cwd = process.cwd( return; } - await git.commit( `Release: v${ version }.`, filePathsToAdd ); + await git.commit( `Release: v${ version }.${ skipCi ? ' [skip ci]' : '' }`, filePathsToAdd ); await git.addTag( `v${ version }` ); } diff --git a/packages/ckeditor5-dev-release-tools/tests/tasks/commitandtag.js b/packages/ckeditor5-dev-release-tools/tests/tasks/commitandtag.js index 6f648a988..7c880fdd2 100644 --- a/packages/ckeditor5-dev-release-tools/tests/tasks/commitandtag.js +++ b/packages/ckeditor5-dev-release-tools/tests/tasks/commitandtag.js @@ -92,7 +92,7 @@ describe( 'commitAndTag()', () => { } ) ); expect( stubs.git.commit ).toHaveBeenCalledExactlyOnceWith( - 'Release: v1.0.0.', + 'Release: v1.0.0. [skip ci]', [ 'package.json', 'packages/ckeditor5-foo/package.json' @@ -100,6 +100,22 @@ describe( 'commitAndTag()', () => { ); } ); + it( 'should not add skip ci to the commit when skipCi is set as false', async () => { + vi.mocked( glob ).mockResolvedValue( [ 'package.json', 'packages/ckeditor5-foo/package.json' ] ); + + await commitAndTag( { version: '1.0.0', packagesDirectory: 'packages', files: [ '**/package.json' ], skipCi: false } ); + + expect( vi.mocked( glob ) ).toHaveBeenCalledExactlyOnceWith( expect.anything(), expect.objectContaining( { + absolute: true, + nodir: true + } ) ); + + expect( stubs.git.commit ).toHaveBeenCalledExactlyOnceWith( + 'Release: v1.0.0.', + expect.anything() + ); + } ); + it( 'should add a tag to the created commit', async () => { vi.mocked( glob ).mockResolvedValue( [ 'package.json' ] ); From a54bc39e138b4f6ee54dea914ea6abb63470fe0f Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Wed, 23 Oct 2024 08:24:12 +0200 Subject: [PATCH 2/2] Wording. --- packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js b/packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js index 0d7b07e2e..4260b9484 100644 --- a/packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js +++ b/packages/ckeditor5-dev-release-tools/lib/tasks/commitandtag.js @@ -16,7 +16,7 @@ const { toUnix } = upath; * @param {string} options.version The commit will contain this param in its message and the tag will have a `v` prefix. * @param {Array.} options.files Array of glob patterns for files to be added to the release commit. * @param {string} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved. - * @param {boolean} [options.skipCi=true] Whether to add [skip ci] to the commit. + * @param {boolean} [options.skipCi=true] Whether to add the "[skip ci]" suffix to the commit message. * @returns {Promise} */ export default async function commitAndTag( { version, files, cwd = process.cwd(), skipCi = true } ) {