Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

import argparse
import subprocess
from datetime import datetime
import io
import itertools
Expand Down Expand Up @@ -113,6 +114,8 @@ def main(original_args=None):
config, config_file, config_newlines, config_file_exists, args.new_version, args.dry_run,
)

_run_commands(defaults, args.dry_run,)

# commit and tag
if vcs:
context = _commit_to_vcs(files, context, config_file, config_file_exists, vcs, args, current_version, new_version)
Expand Down Expand Up @@ -270,7 +273,7 @@ def _load_configuration(config_file, explicit_config, defaults):

defaults.update(dict(config.items("bumpversion")))

for listvaluename in ("serialize",):
for listvaluename in ("serialize", 'commands'):
try:
value = config.get("bumpversion", listvaluename)
defaults[listvaluename] = list(
Expand Down Expand Up @@ -628,6 +631,15 @@ def _update_config_file(
)


def _run_commands(defaults, dry_run):
"""Run additional default commands."""
for command in defaults.get('commands', []):
if dry_run:
logger.info('Would run %s command', command)
else:
subprocess.check_output(command, shell=True)


def _commit_to_vcs(files, context, config_file, config_file_exists, vcs, args, current_version, new_version):
commit_files = [f.path for f in files]
if config_file_exists:
Expand Down