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
4 changes: 2 additions & 2 deletions src/adapters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ interface IRepoAdapter {

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

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

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

createPullRequest(repo: IRepo, message: string): Promise<void>;

Expand Down
12 changes: 7 additions & 5 deletions src/adapters/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,24 @@ abstract class GitAdapter implements IRepoAdapter {
}
}

public async commitRepo(repo: IRepo): Promise<void> {
public async commitRepo(repo: IRepo, noVerify:boolean): Promise<void> {
const {
migration: { spec },
} = this.migrationContext;
const options = noVerify ? ['--no-verify'] : undefined;
await this.git(repo).add('.');
await this.git(repo).commit(`${spec.title} [shepherd]`);
await this.git(repo).commit(`${spec.title} [shepherd]`, options);
}

public async resetChangedFiles(repo: IRepo): Promise<void> {
await this.git(repo).reset(['--hard']);
await this.git(repo).clean('f', ['-d']);
}

public async pushRepo(repo: IRepo, force: boolean): Promise<void> {
const options = force ? ['--force'] : undefined;

public async pushRepo(repo: IRepo, force: boolean, noVerify: boolean): Promise<void> {
const options = []
if (force) { options.push('--force') }
if (noVerify) { options.push('--no-verify') }
await this.git(repo).push('origin', 'HEAD', options);
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class GithubAdapter extends GitAdapter {
await this.git(repo).reset(['--hard', `origin/${defaultBranch}`]);
}

public async pushRepo(repo: IRepo, force: boolean): Promise<void> {
public async pushRepo(repo: IRepo, force: boolean, noVerify: boolean): Promise<void> {
let shouldForce = false;

// First, get any changes from the remote
Expand All @@ -127,7 +127,7 @@ class GithubAdapter extends GitAdapter {
shouldForce = true;
}

await super.pushRepo(repo, force || shouldForce);
await super.pushRepo(repo, force || shouldForce, noVerify);
}

public async createPullRequest(repo: IRepo, message: string): Promise<void> {
Expand Down
7 changes: 6 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,16 @@ applyCommand.option(
);
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('-n, --no-verify', 'Skips pre-commit hooks');
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');
addReposOption(pushCommand);
pushCommand.option('-n, --no-verify', 'Skips pre-push hooks');
pushCommand.option('-f, --force', 'Force push, skipping any safety checks');
pushCommand.action(handleCommand(push));

Expand Down
5 changes: 3 additions & 2 deletions src/commands/commit.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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.noVerify);

spinner.succeed('Changes committed');
} catch (e) {
logger.error(e);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default async (context: IMigrationContext, options: any) => {
await forEachRepo(context, async (repo) => {
const spinner = logger.spinner('Pushing changes');
try {
await adapter.pushRepo(repo, options.force);
await adapter.pushRepo(repo, options.force, options.noVerify);
spinner.succeed('Changes pushed');
} catch (e) {
logger.error(e);
Expand Down