@task
def hotfix(ctx, name, finish=False, push=False):
 print 'Checking out master to calculate curent version'
 ctx.run('git checkout master')
 latest_version = latest_tag_info()['current_version']
 print 'Current version is: {}'.format(latest_version)
 (major, minor, patch) = latest_version.split('.')
 next_patch_version = '.'.join([major, minor, str((int(patch) + 1))])
 print 'Bumping to next patch version: {}'.format(next_patch_version)
 print 'Renaming branch...'
 new_branch_name = 'hotfix/{}'.format(next_patch_version)
 ctx.run('git checkout {}'.format(name), echo=True)
 ctx.run('git branch -m {}'.format(new_branch_name), echo=True)
 if finish:
  ctx.run('git flow hotfix finish {}'.format(next_patch_version), echo=True, pty=True)
 if push:
  ctx.run('git push origin master', echo=True)
  ctx.run('git push --tags', echo=True)
  ctx.run('git push origin develop', echo=True)

@ task def hotfix ( ctx , name , finish = False , push = False ) : print 'Checking out master to calculate curent version' ctx . run ( 'git checkout master' ) latest_version = latest_tag_info ( ) [ 'current_version' ] print 'Current version is: {}' . format ( latest_version ) ( major , minor , patch ) = latest_version . split ( '.' ) next_patch_version = '.' . join ( [ major , minor , str ( ( int ( patch ) + 1 ) ) ] ) print 'Bumping to next patch version: {}' . format ( next_patch_version ) print 'Renaming branch...' new_branch_name = 'hotfix/{}' . format ( next_patch_version ) ctx . run ( 'git checkout {}' . format ( name ) , echo = True ) ctx . run ( 'git branch -m {}' . format ( new_branch_name ) , echo = True ) if finish : ctx . run ( 'git flow hotfix finish {}' . format ( next_patch_version ) , echo = True , pty = True ) if push : ctx . run ( 'git push origin master' , echo = True ) ctx . run ( 'git push --tags' , echo = True ) ctx . run ( 'git push origin develop' , echo = True )
rename hotfix branch to hotfix/<next-patch-version> and optionally finish hotfix .