def _grab_version(self): """Set the version to a non-development version.""" original_version = self.vcs.version logger.debug("Extracted version: %s", original_version) if original_version is None: logger.critical('No version found.') sys.exit(1) suggestion = utils.cleanup_version(original_version) new_version = utils.ask_version("Enter version", default=suggestion) if not new_version: new_version = suggestion self.data['original_version'] = original_version self.data['new_version'] = new_version
def _update_version(self): """Ask for and store a new dev version string.""" #current = self.vcs.version current = self.data['new_version'] # Clean it up to a non-development version. current = utils.cleanup_version(current) # Try to make sure that the suggestion for next version after # 1.1.19 is not 1.1.110, but 1.1.20. current_split = current.split('.') major = '.'.join(current_split[:-1]) minor = current_split[-1] try: minor = int(minor) + 1 suggestion = '.'.join([major, str(minor)]) except ValueError: # Fall back on simply updating the last character when it is # an integer. try: last = int(current[-1]) + 1 suggestion = current[:-1] + str(last) except ValueError: logger.warn("Version does not end with a number, so we can't " "calculate a suggestion for a next version.") suggestion = None print("Current version is %r" % current) q = "Enter new development version ('.dev0' will be appended)" version = utils.ask_version(q, default=suggestion) if not version: version = suggestion if not version: logger.error("No version entered.") sys.exit() self.data['new_version'] = version dev_version = self.data['dev_version_template'] % self.data self.data['dev_version'] = dev_version logger.info("New version string is %r", dev_version) self.vcs.version = self.data['dev_version']