summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2016-03-09 14:19:05 +0200
committerLars Wirzenius <liw@liw.fi>2016-03-09 14:34:25 +0200
commite7e4ba38a93fb5f05b1505e6b10c75bbac1d831b (patch)
tree4cec643e5366ec67389949f4217934c403653568
parentd2eea7ea2c361920bf416bf2255571f11787b302 (diff)
downloadbumper-e7e4ba38a93fb5f05b1505e6b10c75bbac1d831b.tar.gz
Check that new version is newer than current
-rw-r--r--NEWS2
-rwxr-xr-xbumper17
-rw-r--r--bumper.yarn30
3 files changed, 44 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 0019cea..2ea1834 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ NEWS for bumper
Version 0.2+git, not yet released
---------------------------------
+* Bumper now checks that the new version is newer than the current
+ version.
Version 0.2, released 2016-02-21
---------------------------------
diff --git a/bumper b/bumper
index ef06fef..624c358 100755
--- a/bumper
+++ b/bumper
@@ -30,9 +30,15 @@ class Bumper(cliapp.Application):
def process_args(self, args):
project_name = self.get_project_name()
version = self.get_version(args)
- version_py = self.find_version_py()
print 'Releasing {} version {}'.format(project_name, version)
+ current_version = self.get_current_version()
+ if not self.version_is_newer(version, current_version):
+ raise cliapp.AppException(
+ 'New version {} is older than current version {}'.format(
+ version, current_version))
+
+ version_py = self.find_version_py()
print '... {}'.format(version_py)
self.write_version_py(version_py, version, '')
@@ -81,6 +87,15 @@ class Bumper(cliapp.Application):
raise cliapp.AppException('Too many version.py in project')
return version_pys[0]
+ def get_current_version(self):
+ return cliapp.runcmd(['python', 'setup.py', '--version']).strip()
+
+ def version_is_newer(self, v1, v2):
+ '''Is v1 newer than v2?'''
+ vi1 = self.parse_version_info(v1, None)
+ vi2 = self.parse_version_info(v2, None)
+ return vi1 > vi2
+
def update_debian_changelog(self, version, msg):
debian_version = '{}-1'.format(version)
cliapp.runcmd(['dch', '-v', debian_version, msg])
diff --git a/bumper.yarn b/bumper.yarn
index 230dda7..5f2c3a5 100644
--- a/bumper.yarn
+++ b/bumper.yarn
@@ -55,10 +55,16 @@ also stored.
GIVEN Python project foo, version controlled by git
AND a file foolib/version.py in foo containing
- ... "__version__ = '0.0'\n__version_info__ = (0, 0)\n"
+ ... "__version__ = '1.0'\n__version_info__ = (1, 0)\n"
AND project foo has Debian packaging
-We run Bumper, and it does several things.
+We run Bumper to update version numbers and tag a new release. We
+first try with a version that's older than the current one.
+
+ WHEN user attempts to run "bumper 0.1" in the foo directory
+ THEN bumper exits with code 1
+
+We now run Bumper properly, and it does its various things.
WHEN user runs "bumper 3.2" in the foo directory
@@ -125,7 +131,7 @@ for Bumper.
dirname = yarnstep.datadir(project)
yarnstep.write_file(os.path.join(dirname, 'setup.py'), '''
from distutils.core import setup
- setup(name='{project}')
+ setup(name='{project}', version='1.0')
'''.format(project=project))
yarnstep.write_file(os.path.join(dirname, 'NEWS'), '''
NEWS for {project}
@@ -156,11 +162,27 @@ for Bumper.
dirname = yarnstep.datadir(project)
os.mkdir(os.path.join(dirname, 'debian'))
cliapp.runcmd(
- ['dch', '--create', '-v', '0.0-1', '--package', project, ''],
+ ['dch', '--create', '-v', '1.0-1', '--package', project, ''],
cwd=dirname)
cliapp.runcmd(['git', 'add', 'debian'], cwd=dirname)
cliapp.runcmd(['git', 'commit', '-m', 'Add debian packaging'], cwd=dirname)
+ IMPLEMENTS WHEN user attempts to run "bumper (\S+)" in the (\S+) directory
+ import cliapp, yarnstep
+ version = yarnstep.get_next_match()
+ dirname = yarnstep.get_next_match_as_datadir_path()
+ bin = yarnstep.srcdir('bumper')
+ returncode, out, err = cliapp.runcmd_unchecked([bin, version], cwd=dirname)
+ yarnstep.write_file(yarnstep.datadir('bumper.exit'), str(returncode))
+
+ IMPLEMENTS THEN bumper exits with code (\d+)
+ import yarnstep
+ expected = yarnstep.get_next_match()
+ actual = yarnstep.cat(yarnstep.datadir('bumper.exit'))
+ print 'expected:', repr(expected)
+ print 'actual:', repr(actual)
+ assert expected == actual
+
IMPLEMENTS WHEN user runs "bumper (\S+)" in the (\S+) directory
import cliapp, yarnstep
version = yarnstep.get_next_match()