def __init__(self, ops):
        if ops.version is None:
            self.version = MwVersion.new_snapshot(ops.branch)
        else:
            self.version = MwVersion(ops.version)
        self.options = ops

        if not os.path.isfile(self.options.conffile):
            logging.error("Configuration file not found: %s",
                          self.options.conffile)
            sys.exit(1)

        self.config = None
        with open(self.options.conffile) as conf:
            self.config = yaml.load(conf)
    def main(self):
        """return value should be usable as an exit code"""
        logging.info("Doing release for %s", self.version.raw)

        if self.version.branch is None:
            logging.debug("No branch, assuming '%s'. Override with --branch.",
                          self.options.branch)
            self.version.branch = self.options.branch

        # No version specified, assuming a snapshot release
        if self.options.version is None:
            self.do_release(
                version=MwVersion.new_snapshot(self.options.branch))
            return 0

        if self.options.previousversion:
            # Given the previous version on the command line
            self.do_release(version=self.version)
            return 0

        no_previous = False
        if self.version.prev_version is None:
            no_previous = True
            if not self.ask("No previous release found. Do you want to make a "
                            "release with no patch?"):
                logging.error('Please specify the correct previous release ' +
                              'on the command line')
                return 1
        if no_previous or self.options.no_previous:
            self.do_release(version=self.version)
        else:
            if not self.ask("Was %s the previous release?" %
                            self.version.prev_version):
                logging.error('Please specify the correct previous release ' +
                              'on the command line')
                return 1

            self.do_release(version=self.version)
        return 0
def test_new_snapshot():
    """Make sure a new snapshot release spits out expected version info"""
    version = MwVersion.new_snapshot()
    assert version.raw.startswith('snapshot-')
    assert version.branch == 'master'
    assert version.major == 'snapshot'
예제 #4
0
def test_new_snapshot():
    """Make sure a new snapshot release spits out expected version info"""
    version = MwVersion.new_snapshot()
    assert version.raw.startswith('snapshot-')
    assert version.branch == 'master'
    assert version.major == 'snapshot'