コード例 #1
0
ファイル: semver2.py プロジェクト: 20c/ctl
    def release(self, repo, **kwargs):
        """
        release and tag a version

        current version needs to be a pre-release version.

        **Arguments**

        - repo (`str`): name of existing repository type plugin instance
        """
        repo_plugin = self.repository(repo)
        repo_plugin.pull()

        version = repo_plugin.version

        # Use semver to parse version
        version = semver.VersionInfo.parse(version)

        if not version.prerelease:
            raise UsageError(
                "Currently not on a pre-release version. Use `bump` or `tag` operation instead"
            )

        version = version.replace(prerelease=None)
        self.tag(version=str(version), repo=repo, **kwargs)
コード例 #2
0
ファイル: venv.py プロジェクト: 20c/ctl
    def venv_validate(self, path=None):
        """
        Validate virtualenv at location

        If no location is supplied the path in `self.output` is checked

        Will raise a `UsageError` on validation failure

        **Keyword Arguments**

        - path (`str`): path to check (should be virtuelenv root directory)
        """

        if not self.venv_exists(path):
            raise UsageError("No virtualenv found at {}".format(
                path or self.output))
コード例 #3
0
ファイル: semver2.py プロジェクト: grizz/ctl
    def tag(self, version, repo, prerelease=None, **kwargs):
        """
        tag a version according to version specified

        **Arguments**

        - version (`str`): tag version (eg. 1.0.0)
        - repo (`str`): name of existing repository type plugin instance

        **Keyword Arguments**
        - prerelease (`str`): identifier if this is a prerelease version
        - release (`bool`): if `True` also run `merge_release`
        """
        repo_plugin = self.repository(repo)
        repo_plugin.pull()

        if not repo_plugin.is_clean:
            raise UsageError("Currently checked out branch is not clean")

        version = semver.VersionInfo.parse(version)

        if prerelease:
            version = version.bump_prerelease(prerelease)

        version_tag = str(version)

        if self.get_config("changelog_validate"):
            # TODO: changelog for pre-releases?
            if not version.prerelease:
                self.validate_changelog(repo, version_tag)

        self.log.info(
            f"Preparing to tag {repo_plugin.checkout_path} as {version_tag}")

        if not os.path.exists(repo_plugin.repo_ctl_dir):
            os.makedirs(repo_plugin.repo_ctl_dir)

        files = []

        self.update_version_files(repo_plugin, version_tag, files)

        repo_plugin.commit(files=files,
                           message=f"Version {version_tag}",
                           push=True)
        repo_plugin.tag(version_tag, message=version_tag, push=True)
コード例 #4
0
ファイル: venv.py プロジェクト: 20c/ctl
    def sync_setup(self,
                   setup_file=".",
                   dry=False,
                   freeze=False,
                   dev=True,
                   **kwargs):
        """
        Syncs setup.py requirements from Pipfile

        **Keyword Arguments**

        - setup_file (`str`): path to `setup.py` file. If not specified
          will check in `.` instead
        - dry (`bool`=`False`): if `True` do a dry run and report what
          updates would be done to `setup.py`
        - freeze (`bool`=`False`): if `True` do frozen pinned versions
          from Pipfile.lock
        - dev (`bool`=`True`): Also fill extras_require with Pipfile dev
          entries
        """

        if not pipenv_setup:
            raise UsageError(
                "Please install `pipenv-setup` to be able to use this command")

        if dry:
            sub_command = "check"
        else:
            sub_command = "sync"

        with self.cwd_ctx(os.path.dirname(setup_file) or "."):
            command = f"pipenv-setup {sub_command} --dev"
            if dev:
                command = f"{command} --dev"
            if not freeze:
                command = f"{command} --pipfile"
            self._run_commands([command], **kwargs)
コード例 #5
0
    def repository(self, target):
        """
        Return plugin instance for repository

        **Arguments**

        - target (`str`): name of a configured repository type plugin
          or filepath to a repository checkout

        **Returns**

        git plugin instance (`GitPlugin`)
        """

        try:
            plugin = self.other_plugin(target)
            if not isinstance(plugin, RepositoryPlugin):
                raise TypeError("The plugin with the name `{}` is not a "
                                "repository type plugin and cannot be used "
                                "as a target".format(target))
        except KeyError:
            if target:
                target = os.path.abspath(target)
            if not target or not os.path.exists(target):
                raise OSError("Target is neither a configured repository "
                              "plugin nor a valid file path: "
                              "{}".format(target))

            plugin = ctl.plugins.git.temporary_plugin(self.ctl, target, target)

        if not self.init_version and not os.path.exists(plugin.version_file):
            raise UsageError(
                "Ctl/VERSION file does not exist. You can set the --init flag to create "
                "it automatically.")

        return plugin
コード例 #6
0
ファイル: version.py プロジェクト: grizz/ctl
    def tag(self, version, repo, **kwargs):
        """
        tag a version according to version specified

        **Arguments**

        - version (`str`): tag version (eg. 1.0.0)
        - repo (`str`): name of existing repository type plugin instance

        **Keyword Arguments**

        - release (`bool`): if `True` also run `merge_release`
        """
        repo_plugin = self.repository(repo)
        repo_plugin.pull()

        if not repo_plugin.is_clean:
            raise UsageError("Currently checked out branch is not clean")

        if kwargs.get("release"):
            self.merge_release(repo=repo)
            repo_plugin.checkout(self.get_config("branch_release") or "master")

        self.log.info(
            f"Preparing to tag {repo_plugin.checkout_path} as {version}")
        if not os.path.exists(repo_plugin.repo_ctl_dir):
            os.makedirs(repo_plugin.repo_ctl_dir)

        files = []

        self.update_version_files(repo_plugin, version, files)

        repo_plugin.commit(files=files,
                           message=f"Version {version}",
                           push=True)
        repo_plugin.tag(version, message=version, push=True)