Exemplo n.º 1
0
    def _grab_version(self, initial=False):
        """Grab the version.

        When initial is False, ask the user for a non-development
        version.  When initial is True, grab the current suggestion.

        """
        original_version = self.vcs.version
        logger.debug("Extracted version: %s", original_version)
        if not original_version:
            logger.critical('No version found.')
            sys.exit(1)
        suggestion = new_version = self.data.get('new_version')
        if not new_version:
            # Get a suggestion.
            breaking = self.data['breaking']
            feature = self.data['feature']
            # Compare the suggestion for the last tag with the current version.
            # The wanted version bump may already have been done.
            last_tag_version = utils.get_last_tag(self.vcs, allow_missing=True)
            if last_tag_version is None:
                print("No tag found. No version bump needed.")
                sys.exit(0)
            else:
                print("Last tag: {}".format(last_tag_version))
            print("Current version: {}".format(original_version))
            params = dict(
                feature=feature,
                breaking=breaking,
                less_zeroes=self.pypiconfig.less_zeroes(),
                levels=self.pypiconfig.version_levels(),
                dev_marker=self.pypiconfig.development_marker(),
            )
            minimum_version = utils.suggest_version(
                last_tag_version, **params)
            if parse_version(minimum_version) <= parse_version(
                    utils.cleanup_version(original_version)):
                print("No version bump needed.")
                sys.exit(0)
            # A bump is needed.  Get suggestion for next version.
            suggestion = utils.suggest_version(
                original_version, **params)
        if not initial:
            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
        self.data['clean_new_version'] = utils.cleanup_version(new_version)
Exemplo n.º 2
0
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        logger.debug("Extracted version: %s", current)
        if not current:
            logger.critical('No version found.')
            sys.exit(1)
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        suggestion = utils.suggest_version(
            current,
            less_zeroes=self.pypiconfig.less_zeroes(),
            levels=self.pypiconfig.version_levels(),
            dev_marker=self.pypiconfig.development_marker(),
        )
        print("Current version is %s" % current)
        q = ("Enter new development version "
             "('%(development_marker)s' will be appended)" % self.data)
        version = utils.ask_version(q, default=suggestion)
        if not version:
            version = suggestion
        if not version:
            logger.error("No version entered.")
            sys.exit(1)

        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 %s", dev_version)
Exemplo n.º 3
0
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        logger.debug("Extracted version: %s", current)
        if not current:
            logger.critical('No version found.')
            sys.exit(1)
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        suggestion = utils.suggest_version(
            current,
            less_zeroes=self.pypiconfig.less_zeroes(),
            levels=self.pypiconfig.version_levels(),
            dev_marker=self.pypiconfig.development_marker(),
        )
        print("Current version is %s" % current)
        q = ("Enter new development version "
             "('%(development_marker)s' will be appended)" % self.data)
        version = utils.ask_version(q, default=suggestion)
        if not version:
            version = suggestion
        if not version:
            logger.error("No version entered.")
            sys.exit(1)

        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 %s",
                    dev_version)
Exemplo n.º 4
0
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        suggestion = utils.suggest_version(current)
        print("Current version is %s" % 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(1)

        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 %s", dev_version)
Exemplo n.º 5
0
    def _ask_for_new_dev_version(self):
        """Ask for and store a new dev version string."""
        current = self.vcs.version
        # Clean it up to a non-development version.
        current = utils.cleanup_version(current)
        suggestion = utils.suggest_version(current)
        print("Current version is %s" % 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(1)

        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 %s",
                    dev_version)