diff --git a/src/adapters/base.ts b/src/adapters/base.ts index 5873fce9..00ebeb24 100644 --- a/src/adapters/base.ts +++ b/src/adapters/base.ts @@ -25,7 +25,7 @@ interface IRepoAdapter { resetRepoBeforeApply(repo: IRepo, force: boolean): Promise; - commitRepo(repo: IRepo): Promise; + commitRepo(repo: IRepo, verify: boolean): Promise; pushRepo(repo: IRepo, force: boolean): Promise; diff --git a/src/adapters/git.ts b/src/adapters/git.ts index d715ac4e..0801c6fe 100644 --- a/src/adapters/git.ts +++ b/src/adapters/git.ts @@ -57,10 +57,14 @@ abstract class GitAdapter implements IRepoAdapter { } } - public async commitRepo(repo: IRepo): Promise { + public async commitRepo(repo: IRepo, verify = true): Promise { const { migration: { spec } } = this.migrationContext; await this.git(repo).add('.'); - await this.git(repo).commit(`${spec.title} [shepherd]`); + const opts: any = {}; + if (!verify) { + opts[`--no-verify`] = null; + } + await this.git(repo).commit(`${spec.title} [shepherd]`, opts); } public async resetChangedFiles(repo: IRepo): Promise { diff --git a/src/cli.ts b/src/cli.ts index 3fc03b95..bc4abb96 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -104,7 +104,11 @@ applyCommand.option('--force-reset-branch', 'Force a reset of the branch before applyCommand.option('--skip-reset-on-error', 'Keep changes in the working tree even if the migration fails', false); applyCommand.action(handleCommand(apply)); -addCommand('commit', 'Commit all changes for the specified migration', true, commit); +const commitCommand = buildCommand('commit', 'Commit all changes for the specified migration'); +addReposOption(commitCommand); +commitCommand.option('--no-verify', 'Skips commit verification checks', false); +commitCommand.action(handleCommand(commit)) + addCommand('reset', 'Reset all changes for the specified migration', true, reset); const pushCommand = buildCommand('push', 'Push all changes for the specified migration'); diff --git a/src/commands/commit.ts b/src/commands/commit.ts index 4bc1c3c2..cf70c9d9 100644 --- a/src/commands/commit.ts +++ b/src/commands/commit.ts @@ -1,16 +1,15 @@ import { IMigrationContext } from '../migration-context'; import forEachRepo from '../util/for-each-repo'; -export default async (context: IMigrationContext) => { +export default async (context: IMigrationContext, options: any) => { const { adapter, logger, } = context; - await forEachRepo(context, async (repo) => { const spinner = logger.spinner('Committing changes'); try { - await adapter.commitRepo(repo); + await adapter.commitRepo(repo, options.verify); spinner.succeed('Changes committed'); } catch (e) { logger.error(e);