Ejemplo n.º 1
0
    def test_set(self, *mocks):
        """Ensure checking for a version being set parses the version"""
        args = self._get_args(set="1.2.3")
        git_version = GitVersion(args)

        new_version = git_version.check_set()

        self.assertEquals("1", new_version.major)
        self.assertEquals("2", new_version.minor)
        self.assertEquals("3", new_version.patch)
Ejemplo n.º 2
0
    def test_bump_no_tag(self, *mocks):
        """
        Ensures bumping when there is no tag produces 0.0.1
        """
        version_mock = self._setup_version(*mocks, version="000000-master")

        args = self._get_args(patch=True)

        git_version = GitVersion(args)

        new_version = git_version.bump()

        self.assertEquals("0.0.1", str(new_version))
Ejemplo n.º 3
0
def main():
    logging.basicConfig(level=getattr(logging, LOG_LEVEL.upper()))

    parser = ArgumentParser()
    subcommand = parser.add_subparsers(dest="subcommand")

    GitVersion.setup_subparser(subcommand)
    WriteFile.setup_subparser(subcommand)

    args = parser.parse_args(default_subparser="version")

    command = args.cls(args)
    sys.exit(command.run())
Ejemplo n.º 4
0
def main():
    logging.basicConfig(level=logging.WARNING)

    parser = ArgumentParser()
    subcommand = parser.add_subparsers(dest='subcommand')

    GitVersion.setup_subparser(subcommand)
    WriteFile.setup_subparser(subcommand)

    args = parser.parse_args(default_subparser='version')

    command = args.cls(args)
    sys.exit(command.run())
Ejemplo n.º 5
0
    def test_stringify_change_prefix_separator(self, *mocks):
        """
        Ensure the prefix separator can be changed
        """
        version_mock = self._setup_version(
            *mocks, version="TestModule/0.0.1-16-g5befeb2"
        )

        args = self._get_args(prefix_separator="-")

        git_version = GitVersion(args)
        new_version_s = git_version.stringify(git_version.version)

        self.assertEquals("TestModule-0.0.1-16-g5befeb2", new_version_s)
Ejemplo n.º 6
0
    def test_bump_rev_rc(self, *mocks):
        """
        Ensures running bump --rc on an RC results in a proper rc tag
        """
        version_mock = self._setup_version(*mocks)

        args = self._get_args(rc=True)

        git_version = GitVersion(args)

        self.assertEquals(version_mock.return_value, git_version.version)

        new_version = git_version.bump()

        self.assertEquals("0.1.28rc2", new_version)
Ejemplo n.º 7
0
    def test_bump_rc_to_stable(self, *mocks):
        """
        Ensures running bump results in a stable, non-rc, release
        """
        version_mock = self._setup_version(*mocks, version="0.1.28rc2")

        args = self._get_args()

        git_version = GitVersion(args)

        self.assertEquals(version_mock.return_value, git_version.version)

        new_version = git_version.bump()

        self.assertEquals("0.1.28", str(new_version))
Ejemplo n.º 8
0
    def test_bump_project_prefix(self, *mocks):
        """
        When bumping a tag with a prefix, include the prefix
        """
        version_mock = self._setup_version(
            *mocks, version="TestModule/0.0.1-16-g5befeb2"
        )

        args = self._get_args(patch=True)

        git_version = GitVersion(args)
        new_version = git_version.bump()
        new_version_s = git_version.stringify(new_version)

        self.assertEquals("TestModule/0.0.2", new_version_s)
Ejemplo n.º 9
0
    def test_bump_project_set_prefix(self, *mocks):
        """
        when bumping a tag and a prefix is specified, use the specified prefix
        """
        version_mock = self._setup_version(
            *mocks, version="TestModule/0.0.1-16-g5befeb2"
        )

        args = self._get_args(patch=True, prefix="NewPrefix")

        git_version = GitVersion(args)
        new_version = git_version.bump()

        new_version_s = git_version.stringify(new_version)

        self.assertEquals("NewPrefix/0.0.2", new_version_s)
Ejemplo n.º 10
0
    def test_get_next_rc_version(self, *mocks):
        """
        Ensures git version stuff is removed from next version
        """
        next_version = GitVersion.get_next_rc_version(RC_VERSION)

        self.assertEquals(["0", "1", "28rc2"], next_version)
Ejemplo n.º 11
0
    def test_bump_no_tag(self, *mocks):
        """
        Ensures bumping when there is no tag produces 0.0.1
        """
        version_mock = self._setup_version(*mocks, version='000000-master')

        args = mock.Mock(calver=False,
                         major=False,
                         minor=False,
                         patch=True,
                         rc=False)

        git_version = GitVersion(args)

        new_version = git_version.bump()

        self.assertEquals([0, 0, 1], new_version)
Ejemplo n.º 12
0
    def test_bump_to_rc(self, *mocks):
        """
        Ensures bumping to an RC properly revs version
        """
        version_mock = self._setup_version(
            *mocks, version='0.1.27-16-g5befeb2-feature--skip-prefix-rows')

        args = mock.Mock(calver=False,
                         major=False,
                         minor=False,
                         patch=True,
                         rc=True)

        git_version = GitVersion(args)

        new_version = git_version.bump()

        self.assertEquals([0, 1, '28rc1'], new_version)
Ejemplo n.º 13
0
    def test_bump_rc_to_stable(self, *mocks):
        """
        Ensures running bump results in a stable, non-rc, release
        """
        version_mock = self._setup_version(*mocks, version='0.1.28rc2')

        args = mock.Mock(calver=False,
                         major=False,
                         minor=False,
                         patch=True,
                         rc=False)

        git_version = GitVersion(args)

        self.assertEquals(version_mock.return_value, git_version.version)

        new_version = git_version.bump()

        self.assertEquals([0, 1, 28], new_version)