diff --git a/git_redmine.py b/git_redmine.py index 15ee6c2..41ff9c6 100644 --- a/git_redmine.py +++ b/git_redmine.py @@ -350,8 +350,9 @@ def get_commits(repo, ref): @redmine.command(name='merge-and-push') @click.option('--issue', default=None, type=int) +@click.option('--validate-msg/--no-validate-msg', default=True) @click.argument('target_branch', default='master') -def merge_and_push(issue, target_branch): +def merge_and_push(issue, validate_msg, target_branch): issue = get_issue(issue or None) repo = get_repo() origin = repo.remote() @@ -373,19 +374,21 @@ def merge_and_push(issue, target_branch): raise click.UsageError('%r is not a local branch.' % target_branch) notes = '
%s
' % repo.git.log('%s..' % target_branch) - for commit in get_commits(repo, target_branch): - if (u'#%s' % get_current_issue()) not in commit.message: - click.echo(click.style('Missing commit number in commit message', fg='red')) - click.echo() - click.echo(commit.message) - raise click.Abort() - if 'rebase' in commit.message: - click.echo() - click.echo('Commit %s contains the word "rebase" :' % commit.hexsha[:8]) - click.echo() - click.echo(''.join([' ' + line for line in commit.message.splitlines()])) - click.echo() - click.confirm('Continue ?', abort=True) + + if validate_msg: + for commit in get_commits(repo, target_branch): + if (u'#%s' % get_current_issue()) not in commit.message: + click.echo(click.style('Missing commit number in commit message', fg='red')) + click.echo() + click.echo(commit.message) + raise click.Abort() + if 'rebase' in commit.message: + click.echo() + click.echo('Commit %s contains the word "rebase" :' % commit.hexsha[:8]) + click.echo() + click.echo(''.join([' ' + line for line in commit.message.splitlines()])) + click.echo() + click.confirm('Continue ?', abort=True) try: click.echo(u'Checking-out branch « %s » ... ' % target_branch, nl=False)