Skip to content

Commit

Permalink
Simplify getting version in create-release script
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed May 18, 2015
1 parent 706174a commit 713a36b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
17 changes: 16 additions & 1 deletion odorik/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,23 @@ class Version(Command):
name = 'version'
description = "Prints program version"

@classmethod
def add_parser(cls, subparser):
"""
Creates parser for command line.
"""
parser = super(Version, cls).add_parser(subparser)
parser.add_argument(
'--bare',
action='store_true',
help='Print only version'
)

def run(self):
self.print({'version': odorik.__version__})
if self.args.bare:
self.println(odorik.__version__)
else:
self.print({'version': odorik.__version__})


@register_command
Expand Down
7 changes: 6 additions & 1 deletion odorik/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ def test_version_json(self):
def test_version_csv(self):
"""Test version printing"""
output = self.execute(['--format', 'csv', 'version'], True)
self.assertTrue('version,0.2' in output)
self.assertTrue('version,{0}'.format(odorik.__version__) in output)

def test_version_bare(self):
"""Test version printing"""
output = self.execute(['version', '--bare'])
self.assertTrue(output.startswith(odorik.__version__))

@httpretty.activate
def test_balance(self):
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-release
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ "x$1" = "x--help" -o "x$1" = "x-h" ] ; then
fi

# Grab version
version=`./odo version`
version=`./odo version --bare`
namever=odorik-$version

# What are we going to build?
Expand Down

0 comments on commit 713a36b

Please sign in to comment.