Skip to content

Commit

Permalink
Refactor version redux
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph committed Oct 16, 2013
1 parent b0c5204 commit 9606c27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
19 changes: 3 additions & 16 deletions changes/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,6 @@
arguments = None


def strip_long_arguments(argument_names):
long_arguments = extract(arguments, argument_names)
return dict([
(key[2:], value) for key, value in long_arguments.items()
])


def extract_version_arguments():
return strip_long_arguments(['--major', '--minor', '--patch'])


def common_arguments():
"""
Return common arguments
Expand All @@ -84,8 +73,6 @@ def common_arguments():
)




def write_new_changelog(app_name, filename, content_lines, dry_run=True):
heading_and_newline = (
'# [Changelog](%s/releases)\n' %
Expand Down Expand Up @@ -349,8 +336,8 @@ def initialise():
def main():
initialise()

commands = ['release', 'changelog', 'test', 'version', 'tag', 'upload',
'install', 'pypi']
commands = ['release', 'changelog', 'test', 'bump_version', 'tag',
'upload', 'install', 'pypi']
suppress_version_prompt_for = ['test', 'upload']

if arguments['--new-version']:
Expand All @@ -368,6 +355,6 @@ def main():
arguments['new_version'] = version.get_new_version(
app_name,
version.current_version(app_name),
**extract_version_arguments()
**version.extract_version_arguments()
)
globals()[command]()
1 change: 1 addition & 0 deletions changes/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def strip_long_arguments(arguments, long_keys):
def extract_version_arguments():
return strip_long_arguments(['--major', '--minor', '--patch'])


def increment(version, major=False, minor=False, patch=True):
"""
Increment a semantic version
Expand Down
2 changes: 2 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from changes import version
from . import BaseTestCase


class VersionTestCase(TestCase):

def test_increment(self):
Expand Down Expand Up @@ -38,6 +39,7 @@ def test_strip_long_arguments(self):
version.strip_long_arguments(arguments, long_keys)
)


class CurrentVersionTestCase(BaseTestCase):

def test_current_version(self):
Expand Down

0 comments on commit 9606c27

Please sign in to comment.