summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2016-02-14 13:14:23 +0200
committerLars Wirzenius <liw@liw.fi>2016-02-14 13:35:46 +0200
commita5f6c84f32855c1516a9d284b0bba33202c7b66c (patch)
tree56176341826c3fce1fc0173917454871fd7e6a53
parent70668a5053c800b9b5a5d4f964f79e503928b11b (diff)
downloadbumper-a5f6c84f32855c1516a9d284b0bba33202c7b66c.tar.gz
Add +git suffix to version after release
-rwxr-xr-xbumper69
-rw-r--r--bumper.yarn56
2 files changed, 106 insertions, 19 deletions
diff --git a/bumper b/bumper
index f2153e3..65aae99 100755
--- a/bumper
+++ b/bumper
@@ -28,29 +28,68 @@ class Bumper(cliapp.Application):
def process_args(self, args):
version = args[0]
filename = args[1]
- self.write_version_py(filename, version)
- self.update_debian_changelog(version)
- self.update_NEWS(version)
- self.commit(version)
+ print 'Preparing release version', version
+
+ print 'Setting version in', filename
+ self.write_version_py(filename, version, '')
+
+ print 'Updating debian/changelog'
+ self.update_debian_changelog(version, 'New upstream version.')
+ self.release_debian_changelog()
+
+ print 'Updating NEWS'
+ self.update_NEWS_for_release(version)
+
+ print 'Committing version updates to git'
+ self.commit(version, 'Prepare to release version {}'.format(version))
+
+ print 'Making release tag'
self.make_release_tag(version)
- def update_debian_changelog(self, version):
+ gitversion = version + '+git'
+ print 'Updating in-development version to', gitversion
+
+ print 'Setting version in', filename
+ self.write_version_py(filename, version, '+git')
+
+ print 'Updating debian/changelog'
+ self.update_debian_changelog(gitversion, '')
+
+ print 'Updating NEWS'
+ self.update_NEWS_for_git(gitversion)
+
+ print 'Committing development version changes'
+ self.commit(
+ version,
+ 'Bump version number post-release to {}'.format(gitversion))
+
+ def update_debian_changelog(self, version, msg):
debian_version = '{}-1'.format(version)
- cliapp.runcmd(['dch', '-v', debian_version, 'New upstream release.'])
+ cliapp.runcmd(['dch', '-v', debian_version, msg])
+
+ def release_debian_changelog(self):
cliapp.runcmd(['dch', '-r', ''])
- def update_NEWS(self, version):
+ def update_NEWS_for_release(self, version):
with open('NEWS') as f:
text = f.read()
date = time.strftime('%Y-%m-%d')
- pattern = r'^Version \d+(\.\d+)*, not yet released$'
+ pattern = r'^Version \d+(\.\d+)*(\+git)?, not yet released$'
replacement = 'Version {}, released {}'.format(version, date)
updated = re.sub(pattern, replacement, text, flags=re.M)
with open('NEWS', 'w') as f:
f.write(updated)
- def commit(self, version):
- msg = 'Prepare to release version {}'.format(version)
+ def update_NEWS_for_git(self, version):
+ with open('NEWS') as f:
+ text = f.read()
+ pattern = r'^Version \d+(\.\d+)*, released \d\d\d\d-\d\d-\d\d$'
+ replacement = 'Version {}, not yet released'.format(version)
+ updated = re.sub(pattern, replacement, text, flags=re.M)
+ with open('NEWS', 'w') as f:
+ f.write(updated)
+
+ def commit(self, version, msg):
cliapp.runcmd(['git', 'commit', '-am', msg])
def make_release_tag(self, version):
@@ -63,13 +102,13 @@ class Bumper(cliapp.Application):
output = cliapp.runcmd(['python', 'setup.py', '--name'])
return output.strip()
- def write_version_py(self, filename, version):
- version_info = self.parse_version_info(version)
+ def write_version_py(self, filename, version, suffix):
+ version_info = self.parse_version_info(version, suffix)
with open(filename, 'w') as f:
- f.write('__version__ = "{}"\n'.format(version))
+ f.write('__version__ = "{}"\n'.format(version + suffix))
f.write('__version_info__ = {!r}\n'.format(version_info))
- def parse_version_info(self, version):
+ def parse_version_info(self, version, suffix):
parts = version.split('.')
result = []
for part in parts:
@@ -77,6 +116,8 @@ class Bumper(cliapp.Application):
result.append(int(part))
except ValueError:
result.append(part)
+ if suffix:
+ result.append(suffix)
return tuple(result)
diff --git a/bumper.yarn b/bumper.yarn
index 4921335..a3d0400 100644
--- a/bumper.yarn
+++ b/bumper.yarn
@@ -70,9 +70,33 @@ to have the right version number.
AND in foo, tag foo-3.2, NEWS matches
... "^Version 3.2, released \\d\\d\\d\\d-\\d\\d-\\d\\d$"
AND in foo, tag foo-3.2, has Debian version 3.2-1
- AND file foolib/version.py in foo contains
- ... "__version__ = "3.2"\n__version_info__ = (3, 2)\n"
+Further, Bumper updates the files in master to have a version number
+with `+git` appended, so that any non-release builds (builds not from
+the tag) won't report a version number that looks like a release.
+
+ AND file foolib/version.py in foo contains
+ ... "__version__ = "3.2+git"\n__version_info__ = (3, 2, '+git')\n"
+ AND file debian/changelog in foo matches
+ ... "foo \\(3\\.2\\+git-1\\) UNRELEASED;"
+ AND file NEWS in foo matches
+ ... "Version 3\\.2\\+git, not yet released"
+
+We can also make a second release.
+
+ WHEN user runs "bumper 3.4 foolib/version.py" in the foo directory
+ THEN git repository foo has tag foo-3.4, signed with AA8CD13C
+ AND in foo, tag foo-3.4, foolib/version.py contains
+ ... "__version__ = "3.4"\n__version_info__ = (3, 4)\n"
+ AND in foo, tag foo-3.4, NEWS matches
+ ... "^Version 3.4, released \\d\\d\\d\\d-\\d\\d-\\d\\d$"
+ AND in foo, tag foo-3.4, has Debian version 3.4-1
+ AND file foolib/version.py in foo contains
+ ... "__version__ = "3.4+git"\n__version_info__ = (3, 4, '+git')\n"
+ AND file debian/changelog in foo matches
+ ... "foo \\(3\\.4\\+git-1\\) UNRELEASED;"
+ AND file NEWS in foo matches
+ ... "Version 3\\.4\\+git, not yet released"
# Appendix: Scenario step implementations
@@ -133,6 +157,8 @@ for Bumper.
cliapp.runcmd(
['dch', '--create', '-v', '0.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 runs "bumper (\S+) (\S+)" in the (\S+) directory
import cliapp, yarnstep
@@ -149,8 +175,21 @@ for Bumper.
wanted_data_escaped = yarnstep.get_next_match()
wanted_data = yarnstep.unescape_backslashes(wanted_data_escaped)
actual_data = yarnstep.cat(os.path.join(dirname, filename))
+ print 'wanted_data:', repr(wanted_data)
+ print 'actual_data:', repr(actual_data)
assert wanted_data == actual_data
+ IMPLEMENTS THEN file (\S+) in (\S+) matches "(.*)"
+ import re, os, yarnstep
+ filename = yarnstep.get_next_match()
+ dirname = yarnstep.get_next_match_as_datadir_path()
+ wanted_data_escaped = yarnstep.get_next_match()
+ wanted_data = yarnstep.unescape_backslashes(wanted_data_escaped)
+ actual_data = yarnstep.cat(os.path.join(dirname, filename))
+ print 'wanted_data:', repr(wanted_data)
+ print 'actual_data:', repr(actual_data)
+ assert re.search(wanted_data, actual_data)
+
IMPLEMENTS THEN in (\S+), tag (\S+), (\S+) contains "(.*)"
import cliapp, yarnstep
dirname = yarnstep.get_next_match_as_datadir_path()
@@ -161,6 +200,8 @@ for Bumper.
actual_data = cliapp.runcmd(
['git', 'cat-file', 'blob', '{}:{}'.format(tag, filename)],
cwd=dirname)
+ print 'wanted_data:', repr(wanted_data)
+ print 'actual_data:', repr(actual_data)
assert wanted_data == actual_data
IMPLEMENTS THEN in (\S+), tag (\S+), (\S+) matches "(.*)"
@@ -173,15 +214,20 @@ for Bumper.
actual_data = cliapp.runcmd(
['git', 'cat-file', 'blob', '{}:{}'.format(tag, filename)],
cwd=dirname)
+ print 'wanted_data:', repr(wanted_data)
+ print 'actual_data:', repr(actual_data)
assert re.search(wanted_data, actual_data, flags=re.M)
IMPLEMENTS THEN in (\S+), tag (\S+), has Debian version (\S+)
- import os, yarnstep
+ import os, cliapp, yarnstep
dirname = yarnstep.get_next_match_as_datadir_path()
- tagname = yarnstep.get_next_match()
+ tag = yarnstep.get_next_match()
version = yarnstep.get_next_match()
- text = yarnstep.cat(os.path.join(dirname, 'debian/changelog'))
+ text = cliapp.runcmd(
+ ['git', 'cat-file', 'blob', '{}:debian/changelog'.format(tag)],
+ cwd=dirname)
line1, _ = text.split('\n', 1)
+ print 'line1:', repr(line1)
assert '({})'.format(version) in line1
assert line1.split()[2] != 'UNRELEASED;'