summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinchinWeb <w_minchin@hotmail.com>2015-08-31 12:55:12 -0600
committerMinchinWeb <w_minchin@hotmail.com>2015-09-15 16:13:29 -0600
commit9a1144034f81ffa76b9e00ac9220f8c024dba1ab (patch)
treeca5989fede51b2917fdef5a339be6177135f1206
parentb26f6de4fc55c219020e49907c24a65ccf6439c8 (diff)
downloadsemantic-version-9a1144034f81ffa76b9e00ac9220f8c024dba1ab.tar.gz
Adjust code to match tests for bumping prerelease versions
-rw-r--r--CREDITS3
-rw-r--r--ChangeLog7
-rw-r--r--semantic_version/base.py19
3 files changed, 23 insertions, 6 deletions
diff --git a/CREDITS b/CREDITS
index c700c77..1506f2a 100644
--- a/CREDITS
+++ b/CREDITS
@@ -18,8 +18,9 @@ Contributors
The project has received contributions from (in alphabetical order):
* Raphaƫl Barrois <raphael.barrois+semver@polytechnique.org> (https://github.com/rbarrois)
-* Michael Hrivnak <mhrivnak@hrivnak.org> (https://github.com/mhrivnak)
* Rick Eyre <rick.eyre@outlook.com> (https://github.com/rickeyre)
+* Michael Hrivnak <mhrivnak@hrivnak.org> (https://github.com/mhrivnak)
+* William Minchin <w_minchin@hotmail.com> (https://github.com/minchinweb)
Contributor license agreement
diff --git a/ChangeLog b/ChangeLog
index fac48ca..7b233fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,13 @@
ChangeLog
=========
+2.4.3 (unreleased)
+------------------
+
+*Bugfix:*
+
+ * Fix handling of bumping pre-release versions, thanks to @minchinweb.
+
2.4.2 (2015-07-02)
------------------
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):