Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/adapters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface IRepoAdapter {

resetRepoBeforeApply(repo: IRepo, force: boolean): Promise<void>;

commitRepo(repo: IRepo): Promise<void>;
commitRepo(repo: IRepo, verify: boolean): Promise<void>;

pushRepo(repo: IRepo, force: boolean): Promise<void>;

Expand Down
8 changes: 6 additions & 2 deletions src/adapters/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ abstract class GitAdapter implements IRepoAdapter {
}
}

public async commitRepo(repo: IRepo): Promise<void> {
public async commitRepo(repo: IRepo, verify = true): Promise<void> {
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<void> {
Expand Down
6 changes: 5 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 2 additions & 3 deletions src/commands/commit.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down