on merge-and-push propose aborting if commit message contains rebase

This commit is contained in:
Benjamin Dauvergne 2019-03-11 15:58:03 +01:00
parent 554460811e
commit 74a2342278
1 changed files with 13 additions and 0 deletions

View File

@ -329,6 +329,11 @@ class MyProgressPrinter(git.RemoteProgress):
print(op_code, cur_count, max_count, cur_count / (max_count or 100.0), message or "NO MESSAGE")
def get_commits(repo, ref):
for commit in git.Commit.iter_items(repo, '%s..' % ref):
yield commit
@redmine.command(name='merge-and-push')
@click.option('--issue', default=None, type=int)
@click.argument('target_branch', default='master')
@ -353,6 +358,14 @@ def merge_and_push(issue, target_branch):
except IndexError:
raise click.UsageError('%r is not a local branch.' % target_branch)
for commit in get_commits(repo, target_branch):
if 'rebase' in commit.message:
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)
repo.branches[target_branch].checkout()