From b3061993e030b09062005b97270b60c284e4a3f3 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 27 Mar 2019 21:18:50 +0100 Subject: [PATCH] report missing issue number in commit messages --- git_redmine.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/git_redmine.py b/git_redmine.py index c43b141..95d250a 100644 --- a/git_redmine.py +++ b/git_redmine.py @@ -265,8 +265,14 @@ def submit(ctx, issue, number_of_commits): message = message.split(MARKER, 1)[0].rstrip('\n') api = get_redmine_api() kwargs = {} + repo = get_repo() + for commit in get_commits(repo, 'master'): + if ('#%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 click.confirm('Push -f this branch to origin ?', default=True): - repo = get_repo() origin = repo.remote() for pi in origin.push(f=True): if pi.flags & pi.ERROR: @@ -362,8 +368,12 @@ 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) - click.echo(notes) 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])