diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-04-22 21:56:21 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-04-22 21:56:21 +0300 |
commit | 2ea78fc9a3d39fe8833062910c512008502b7ae8 (patch) | |
tree | 6a6615a1b73eb7e2c70832ca3af22a574665d975 | |
parent | faf0ad5bcab05b74ee0bfd5a3534c47d66889eca (diff) | |
download | bumper-2ea78fc9a3d39fe8833062910c512008502b7ae8.tar.gz |
refactor: Combine code for version version files
-rwxr-xr-x | bumper | 39 |
1 files changed, 15 insertions, 24 deletions
@@ -39,20 +39,17 @@ class Bumper(cliapp.Application): 'New version {} is older than current version {}'.format( version, current_version)) - version_py = self.find_version_file('version.py') - if version_py: - print '... {}'.format(version_py) - self.write_version_py(version_py, version, '') - - version_txt = self.find_version_file('version.txt') - if version_txt: - print '... {}'.format(version_txt) - self.write_version_txt(version_txt, version, '') + version_files = [ + ('version.py', self.write_version_py), + ('version.txt', self.write_version_txt), + ('version.yaml', self.write_version_yaml), + ] - version_yaml = self.find_version_file('version.yaml') - if version_yaml: - print '... {}'.format(version_yaml) - self.write_version_yaml(version_yaml, version, '') + for basename, func in version_files: + filename = self.find_version_file(basename) + if filename: + print '.. {}'.format(filename) + func(filename, version, '') print '... debian/changelog' self.update_debian_changelog(version, '') @@ -70,17 +67,11 @@ class Bumper(cliapp.Application): gitversion = version + '+git' print 'Updating in-development version to', gitversion - if version_py: - print '... {}'.format(version_py) - self.write_version_py(version_py, version, '+git') - - if version_txt: - print '... {}'.format(version_txt) - self.write_version_txt(version_txt, version, '+git') - - if version_yaml: - print '... {}'.format(version_yaml) - self.write_version_yaml(version_yaml, version, '+git') + for basename, func in version_files: + filename = self.find_version_file(basename) + if filename: + print '... {}'.format(filename) + func(filename, version, '+git') print '... debian/changelog' self.update_debian_changelog(version, 'New upstream version.') |