Skip to content

Commit

Permalink
Refactor extract_version_arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph committed Sep 21, 2013
1 parent a367d71 commit 3ba87ee
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions changes/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ def extract(dictionary, keys):
(k, dictionary[k]) for k in keys if k in dictionary
)

def extract_version_arguments(arguments):
version_arguments = extract(arguments, ['--major', '--minor', '--patch'])
return dict([
(key[2:], value) for key, value in version_arguments.items()
])

def increment(version, major=False, minor=False, patch=True):
"""
Expand Down Expand Up @@ -207,7 +212,6 @@ def changelog(arguments):
git_log_commands.pop()
log.debug('sniffing initial release, drop tags: %s', git_log_commands)
git_log_content = execute(git_log_commands, dry_run=False)
log.debug('result: %s' % git_log_content)

for index, line in enumerate(git_log_content):
# http://stackoverflow.com/a/468378/5549
Expand Down Expand Up @@ -260,13 +264,13 @@ def commit_version_change(arguments):
new_version = arguments['new_version']

commands = [
'git', 'ci', '-m', new_version,
'git', 'ci', '-mx', new_version,
'%s/__init__.py' % app_name, CHANGELOG
]

execute(commands, dry_run=dry_run)

execute(['git', 'push'], dry_run=dry_run)
if not (execute(commands, dry_run=dry_run) and
execute(['git', 'push'], dry_run=dry_run)):
raise Exception('Version change commit failed')


def test(arguments):
Expand All @@ -275,7 +279,8 @@ def test(arguments):
if arguments['--tox']:
command = 'tox'

return execute([command], dry_run=dry_run)
if not execute([command], dry_run=False):
raise Exception('Test command failed')


def make_virtualenv():
Expand Down Expand Up @@ -382,7 +387,7 @@ def release(arguments):
pypi(arguments)
tag(arguments)
except:
log.error('Error releasing')
log.exception('Error releasing')


def main():
Expand All @@ -408,11 +413,6 @@ def main():
arguments['new_version'] = get_new_version(
app_name,
current_version(app_name),
**dict([
(key[2:], value)
for key, value in
extract(arguments, ['--major', '--minor', '--patch'])
.items()
])
**extract_version_arguments(arguments)
)
globals()[command](arguments)

0 comments on commit 3ba87ee

Please sign in to comment.