From 9a1144034f81ffa76b9e00ac9220f8c024dba1ab Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Mon, 31 Aug 2015 12:55:12 -0600 Subject: Adjust code to match tests for bumping prerelease versions --- semantic_version/base.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'semantic_version') diff --git a/semantic_version/base.py b/semantic_version/base.py index 841c5f3..4d9b87e 100644 --- a/semantic_version/base.py +++ b/semantic_version/base.py @@ -89,15 +89,24 @@ class Version(object): return int(value) def next_major(self): - return Version('.'.join(str(x) for x in [self.major + 1, 0, 0])) + if self.prerelease and self.minor is 0 and self.patch is 0: + return Version('.'.join(str(x) for x in [self.major, self.minor, self.patch])) + else: + return Version('.'.join(str(x) for x in [self.major + 1, 0, 0])) def next_minor(self): - return Version( - '.'.join(str(x) for x in [self.major, self.minor + 1, 0])) + if self.prerelease and self.patch is 0: + return Version('.'.join(str(x) for x in [self.major, self.minor, self.patch])) + else: + return Version( + '.'.join(str(x) for x in [self.major, self.minor + 1, 0])) def next_patch(self): - return Version( - '.'.join(str(x) for x in [self.major, self.minor, self.patch + 1])) + if self.prerelease: + return Version('.'.join(str(x) for x in [self.major, self.minor, self.patch])) + else: + return Version( + '.'.join(str(x) for x in [self.major, self.minor, self.patch + 1])) @classmethod def coerce(cls, version_string, partial=False): -- cgit v1.2.1