From 74a2342278ec7b66c1a8a1eace662ca935339b5f Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 11 Mar 2019 15:58:03 +0100 Subject: [PATCH] on merge-and-push propose aborting if commit message contains rebase --- git_redmine.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/git_redmine.py b/git_redmine.py index 44d5c77..8f9f735 100644 --- a/git_redmine.py +++ b/git_redmine.py @@ -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()