From 056cf9890b5691303bd32eb3252dcf55aaea0d89 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 14 Feb 2016 13:43:11 +0200 Subject: Find version.py automatically --- bumper | 13 ++++++++++++- bumper.yarn | 9 ++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bumper b/bumper index 65aae99..b01be43 100755 --- a/bumper +++ b/bumper @@ -27,9 +27,10 @@ class Bumper(cliapp.Application): def process_args(self, args): version = args[0] - filename = args[1] print 'Preparing release version', version + filename = self.find_version_py() + print 'Setting version in', filename self.write_version_py(filename, version, '') @@ -63,6 +64,16 @@ class Bumper(cliapp.Application): version, 'Bump version number post-release to {}'.format(gitversion)) + def find_version_py(self): + output = cliapp.runcmd(['git', 'ls-files']) + filenames = [x.strip() for x in output.splitlines()] + version_pys = [x for x in filenames if x.endswith('/version.py')] + if len(version_pys) == 0: + raise cliapp.AppException('No version.py in project') + elif len(version_pys) > 1: + raise cliapp.AppException('Too many version.py in project') + return version_pys[0] + 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 d204a96..230dda7 100644 --- a/bumper.yarn +++ b/bumper.yarn @@ -60,7 +60,7 @@ also stored. We run Bumper, and it does several things. - WHEN user runs "bumper 3.2 foolib/version.py" in the foo directory + WHEN user runs "bumper 3.2" in the foo directory Bumper creates a git tag for the release, and updates files in the tag to have the right version number. @@ -85,7 +85,7 @@ the tag) won't report a version number that looks like a release. We can also make a second release. - WHEN user runs "bumper 3.4 foolib/version.py" in the foo directory + WHEN user runs "bumper 3.4" 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" @@ -161,13 +161,12 @@ for Bumper. 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 + IMPLEMENTS WHEN user runs "bumper (\S+)" in the (\S+) directory import cliapp, yarnstep version = yarnstep.get_next_match() - filename = yarnstep.get_next_match() dirname = yarnstep.get_next_match_as_datadir_path() bin = yarnstep.srcdir('bumper') - cliapp.runcmd([bin, version, filename], cwd=dirname) + cliapp.runcmd([bin, version], cwd=dirname) IMPLEMENTS THEN file (\S+) in (\S+) contains "(.*)" import os, yarnstep -- cgit v1.2.1