Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix verbose tags #6

Merged
merged 2 commits into from
Feb 2, 2018
Merged
Show file tree
Hide file tree
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
75 changes: 39 additions & 36 deletions bumpversion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,49 +876,52 @@ def main(original_args=None):

assert vcs.is_usable(), "Did find '{}' unusable, unable to commit.".format(vcs.__name__)

do_commit = (not args.dry_run) and args.commit
do_tag = (not args.dry_run) and args.tag

logger.info("{} {} commit".format(
"Would prepare" if not do_commit else "Preparing",
vcs.__name__,
))

for path in commit_files:
logger.info("{} changes in file '{}' to {}".format(
"Would add" if not do_commit else "Adding",
path,
prepare_commit = args.commit
prepare_tag = args.tag
commit_changes = (not args.dry_run) and prepare_commit
commit_tag = (not args.dry_run) and prepare_tag

if prepare_commit:
logger.info("{} {} commit".format(
"Would prepare" if not commit_changes else "Preparing",
vcs.__name__,
))

if do_commit:
vcs.add_path(path)
for path in commit_files:
logger.info("{} changes in file '{}' to {}".format(
"Would add" if not commit_changes else "Adding",
path,
vcs.__name__,
))

vcs_context = {
"current_version": args.current_version,
"new_version": args.new_version,
}
vcs_context.update(time_context)
vcs_context.update(prefixed_environ())
if commit_changes:
vcs.add_path(path)

commit_message = args.message.format(**vcs_context)
vcs_context = {
"current_version": args.current_version,
"new_version": args.new_version,
}
vcs_context.update(time_context)
vcs_context.update(prefixed_environ())

logger.info("{} to {} with message '{}'".format(
"Would commit" if not do_commit else "Committing",
vcs.__name__,
commit_message,
))
commit_message = args.message.format(**vcs_context)

if do_commit:
vcs.commit(message=commit_message)
logger.info("{} to {} with message '{}'".format(
"Would commit" if not commit_changes else "Committing",
vcs.__name__,
commit_message,
))

tag_name = args.tag_name.format(**vcs_context)
logger.info("{} '{}' in {}".format(
"Would tag" if not do_tag else "Tagging",
tag_name,
vcs.__name__
))
if commit_changes:
vcs.commit(message=commit_message)

if do_tag:
vcs.tag(tag_name)
if prepare_tag:
tag_name = args.tag_name.format(**vcs_context)
logger.info("{} '{}' in {}".format(
"Would tag" if not commit_tag else "Tagging",
tag_name,
vcs.__name__
))

if commit_tag:
vcs.tag(tag_name)
5 changes: 0 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,11 +1145,6 @@ def test_log_commitmessage_if_no_commit_tag_but_usable_vcs(tmpdir, vcs):
tag = False

|
info|Would prepare Git commit|
info|Would add changes in file 'please_touch_me.txt' to Git|
info|Would add changes in file '.bumpversion.cfg' to Git|
info|Would commit to Git with message 'Bump version: 0.3.3 \u2192 0.3.4'|
info|Would tag 'v0.3.4' in Git|
""").strip()

if vcs == "hg":
Expand Down