summaryrefslogtreecommitdiff
path: root/semantic_version
diff options
context:
space:
mode:
Diffstat (limited to 'semantic_version')
-rw-r--r--semantic_version/__init__.py2
-rw-r--r--semantic_version/base.py21
-rw-r--r--semantic_version/compat.py2
-rw-r--r--semantic_version/django_fields.py4
4 files changed, 19 insertions, 10 deletions
diff --git a/semantic_version/__init__.py b/semantic_version/__init__.py
index 07de3a5..94e0a8d 100644
--- a/semantic_version/__init__.py
+++ b/semantic_version/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (c) 2012-2014 The python-semanticversion project
+# Copyright (c) The python-semanticversion project
# This code is distributed under the two-clause BSD License.
diff --git a/semantic_version/base.py b/semantic_version/base.py
index d0f5db8..7451e14 100644
--- a/semantic_version/base.py
+++ b/semantic_version/base.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (c) 2012-2014 The python-semanticversion project
+# Copyright (c) The python-semanticversion project
# This code is distributed under the two-clause BSD License.
from __future__ import unicode_literals
@@ -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):
diff --git a/semantic_version/compat.py b/semantic_version/compat.py
index 4dd60fe..b17468f 100644
--- a/semantic_version/compat.py
+++ b/semantic_version/compat.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (c) 2012-2014 The python-semanticversion project
+# Copyright (c) The python-semanticversion project
# This code is distributed under the two-clause BSD License.
diff --git a/semantic_version/django_fields.py b/semantic_version/django_fields.py
index a0c6979..eba8658 100644
--- a/semantic_version/django_fields.py
+++ b/semantic_version/django_fields.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (c) 2012-2014 The python-semanticversion project
+# Copyright (c) The python-semanticversion project
# This code is distributed under the two-clause BSD License.
from __future__ import unicode_literals
@@ -18,7 +18,7 @@ class BaseSemVerField(models.CharField):
super(BaseSemVerField, self).__init__(*args, **kwargs)
def get_prep_value(self, obj):
- return str(obj)
+ return None if obj is None else str(obj)
def get_db_prep_value(self, value, connection, prepared=False):
if not prepared: