Skip to content

Commit

Permalink
Merge pull request #1 from cirulls/devel
Browse files Browse the repository at this point in the history
add support for commit message in release
  • Loading branch information
José Dinuncio committed May 3, 2016
2 parents 970e212 + e61aa0f commit f98a5be
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions source_control/gitflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,16 @@
This option is only used with the command 'hotfix', action 'start'.
required: false
default: (empty string)
message:
description:
- Commit message to use when finishing a release.
This option is only used with the command 'release', action 'finish'.
required: false
default: " "
author: José Dinuncio
author:
- José Dinuncio - @jdinuncio
- Extended by Sandro Cirulli - @cirulls
'''

EXAMPLES = '''
Expand All @@ -96,6 +104,9 @@
# Finish a release branch named '1.5'
- gitflow: path={{ path }} command=release action=finish name=1.5
# Finish a release branch named '1.5' with a commit message
- gitflow: path={{ path }} command=release action=finish name=1.5 message="dummy message"
# Get git-flow version
- gitflow: command=version
Expand Down Expand Up @@ -133,9 +144,9 @@ def _gitflow_init(module, git, path):
module.exit_json(changed=True, msg=err, command=cmd)


def _gitflow_branch(module, git, command, path, action, name, base, remote):
def _gitflow_branch(module, git, command, path, action, name, base, remote, message):
"""git-flow branch commands (feature, release, hotfix)."""
cmd = _get_cmd(git, command, action, name, base, remote)
cmd = _get_cmd(git, command, action, name, base, remote, message)
branches = _list(module, git, command, path)
_exit_if_unchanged(module, cmd, branches, action, name)

Expand Down Expand Up @@ -165,7 +176,7 @@ def _list(module, git, command, path):
return dict(list=lst, current=current)


def _get_cmd(git, command, action, name, base, remote):
def _get_cmd(git, command, action, name, base, remote, message):
"""Returns a string representing the command to execute."""
# git flow {command} {action} {name}
cmd = '{0} flow {1} {2} {3}'
Expand All @@ -175,8 +186,11 @@ def _get_cmd(git, command, action, name, base, remote):
elif action == 'pull':
# git flow feature pull {remote} {name}
cmd = '{0} flow {1} {4} {2}'
elif (command, action) == ('release', 'finish'):
# git flow release finish -m"{message}" {name}
cmd = '{0} flow {1} {2} -m{6!r} {3}'

cmd = cmd.format(git, command, action, name, base, remote)
cmd = cmd.format(git, command, action, name, base, remote, message)
return cmd


Expand All @@ -202,6 +216,7 @@ def main():
executable=dict(required=False, default=GIT_EXECUTABLE),
remote=dict(required=False, default=''),
base=dict(required=False, default=''),
message=dict(required=False, default=' '),
)
)

Expand All @@ -212,6 +227,7 @@ def main():
name = module.params['name']
remote = module.params['remote']
base = module.params['base']
message = module.params['message']

if command == 'version':
_gitflow_version(module, git)
Expand All @@ -223,7 +239,7 @@ def main():
# not declared in module's command choices.
elif command in ['feature', 'release', 'hotfix', 'support']:
_gitflow_branch(module, git, command, path, action, name,
base, remote)
base, remote, message)


# import module snippets
Expand Down

0 comments on commit f98a5be

Please sign in to comment.