Skip to content

Commit

Permalink
fix #9: make tag_name and message work from .cfg
Browse files Browse the repository at this point in the history
+regression test
  • Loading branch information
peritus committed Aug 3, 2013
1 parent 0fd2da7 commit 9192f7d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bumpversion/__init__.py
Expand Up @@ -281,11 +281,11 @@ def main(args=None):

parser3.add_argument('--tag-name', metavar='TAG_NAME',
help='Tag name (only works with --tag)',
default='v{new_version}')
default=defaults.get('tag_name', 'v{new_version}'))

parser3.add_argument('--message', '-m', metavar='COMMIT_MSG',
help='Commit message',
default='Bump version: {current_version} → {new_version}')
default=defaults.get('message', 'Bump version: {current_version} → {new_version}'))

files = []
if 'files' in defaults:
Expand Down
27 changes: 26 additions & 1 deletion tests.py
Expand Up @@ -489,8 +489,33 @@ def test_tag_name(tmpdir, vcs):

main(['patch', '--current-version', '31.1.1', '--commit', '--tag', 'VERSION', '--tag-name', 'ReleasedVersion-{new_version}'])

tag_out = subprocess.check_output([vcs, {"git": "tag", "hg": "tags"}[vcs]])

assert b'ReleasedVersion-31.1.2' in tag_out

@pytest.mark.parametrize(("vcs"), [("git"), ("hg")])
def test_message_from_config_file(tmpdir, capsys, vcs):
tmpdir.chdir()
subprocess.check_call([vcs, "init"])
tmpdir.join("VERSION").write("400.0.0")
subprocess.check_call([vcs, "add", "VERSION"])
subprocess.check_call([vcs, "commit", "-m", "initial commit"])

tmpdir.join(".bumpversion.cfg").write("""[bumpversion]
current_version: 400.0.0
new_version: 401.0.0
commit: True
tag: True
message: {current_version} was old, {new_version} is new
tag_name: from-{current_version}-to-{new_version}""")

main(['major', 'VERSION'])

log = subprocess.check_output([vcs, "log", "-p"])

assert b'400.0.0 was old, 401.0.0 is new' in log

tag_out = subprocess.check_output([vcs, {"git": "tag", "hg": "tags"}[vcs]])

assert b'ReleasedVersion-31.1.2' in tag_out
assert b'from-400.0.0-to-401.0.0' in tag_out

0 comments on commit 9192f7d

Please sign in to comment.