def test_find_increment_type_none():
    messages = NONE_INCREMENT_CC
    commits = [GitCommit(rev="test", title=message) for message in messages]
    increment_type = bump.find_increment(
        commits, regex=semantic_version_pattern, increments_map=semantic_version_map
    )
    assert increment_type is None
def test_find_increment_type_major_sve():
    messages = MAJOR_INCREMENTS_SVE
    commits = [GitCommit(rev="test", title=message) for message in messages]
    increment_type = bump.find_increment(
        commits, regex=semantic_version_pattern, increments_map=semantic_version_map
    )
    assert increment_type == "MAJOR"
def test_find_increment(messages, expected_type):
    commits = [GitCommit(rev="test", title=message) for message in messages]
    increment_type = bump.find_increment(
        commits,
        regex=ConventionalCommitsCz.bump_pattern,
        increments_map=ConventionalCommitsCz.bump_map,
    )
    assert increment_type == expected_type
示例#4
0
 def find_increment(self, commits: List[git.GitCommit]) -> Optional[str]:
     bump_pattern = self.cz.bump_pattern
     bump_map = self.cz.bump_map
     if not bump_map or not bump_pattern:
         raise NoPatternMapError(
             f"'{self.config.settings['name']}' rule does not support bump")
     increment = bump.find_increment(commits,
                                     regex=bump_pattern,
                                     increments_map=bump_map)
     return increment
示例#5
0
 def find_increment(self, commits: List[git.GitCommit]) -> Optional[str]:
     bump_pattern = self.cz.bump_pattern
     bump_map = self.cz.bump_map
     if not bump_map or not bump_pattern:
         out.error(f"'{self.config.settings['name']}' rule does not support bump")
         raise SystemExit(NO_PATTERN_MAP)
     increment = bump.find_increment(
         commits, regex=bump_pattern, increments_map=bump_map
     )
     return increment
def test_find_increment_sve(messages, expected_type):
    commits = [GitCommit(rev="test", title=message) for message in messages]
    increment_type = bump.find_increment(commits,
                                         regex=semantic_version_pattern,
                                         increments_map=semantic_version_map)
    assert increment_type == expected_type
示例#7
0
    def __call__(self):
        """Steps executed to bump."""
        try:
            current_version_instance: Version = Version(self.parameters["version"])
        except TypeError:
            out.error("[NO_VERSION_SPECIFIED]")
            out.error("Check if current version is specified in config file, like:")
            out.error("version = 0.4.3")
            raise SystemExit(NO_VERSION_SPECIFIED)

        # Initialize values from sources (conf)
        current_version: str = self.config["version"]
        tag_format: str = self.parameters["tag_format"]
        bump_commit_message: str = self.parameters["bump_message"]
        current_tag_version: str = bump.create_tag(
            current_version, tag_format=tag_format
        )
        files: list = self.parameters["files"]
        dry_run: bool = self.parameters["dry_run"]

        is_yes: bool = self.arguments["yes"]
        prerelease: str = self.arguments["prerelease"]
        increment: Optional[str] = self.arguments["increment"]

        is_initial = self.is_initial_tag(current_tag_version, is_yes)
        commits = git.get_commits(current_tag_version, from_beginning=is_initial)

        # No commits, there is no need to create an empty tag.
        # Unless we previously had a prerelease.
        if not commits and not current_version_instance.is_prerelease:
            out.error("[NO_COMMITS_FOUND]")
            out.error("No new commits found.")
            raise SystemExit(NO_COMMITS_FOUND)

        if increment is None:
            bump_pattern = self.cz.bump_pattern
            bump_map = self.cz.bump_map
            if not bump_map or not bump_pattern:
                out.error(f"'{self.config['name']}' rule does not support bump")
                raise SystemExit(NO_PATTERN_MAP)
            increment = bump.find_increment(
                commits, regex=bump_pattern, increments_map=bump_map
            )

        # Increment is removed when current and next version
        # are expected to be prereleases.
        if prerelease and current_version_instance.is_prerelease:
            increment = None

        new_version = bump.generate_version(
            current_version, increment, prerelease=prerelease
        )
        new_tag_version = bump.create_tag(new_version, tag_format=tag_format)
        message = bump.create_commit_message(
            current_version, new_version, bump_commit_message
        )

        # Report found information
        out.write(message)
        out.write(f"tag to create: {new_tag_version}")
        out.write(f"increment detected: {increment}")

        # Do not perform operations over files or git.
        if dry_run:
            raise SystemExit()

        config.set_key("version", new_version.public)
        bump.update_version_in_files(current_version, new_version.public, files)
        c = git.commit(message, args="-a")
        if c.err:
            out.error(c.err)
            raise SystemExit(COMMIT_FAILED)
        c = git.tag(new_tag_version)
        if c.err:
            out.error(c.err)
            raise SystemExit(TAG_FAILED)
        out.success("Done!")
示例#8
0
def test_find_increment(messages, expected_type):
    commits = [GitCommit(rev="test", title=message) for message in messages]
    increment_type = bump.find_increment(commits)
    assert increment_type == expected_type
def test_find_increment_type_none():
    messages = NONE_INCREMENT_CC
    increment_type = bump.find_increment(messages,
                                         regex=semantic_version_pattern,
                                         increments_map=semantic_version_map)
    assert increment_type is None
def test_find_increment_type_major_sve():
    messages = MAJOR_INCREMENTS_SVE
    increment_type = bump.find_increment(messages,
                                         regex=semantic_version_pattern,
                                         increments_map=semantic_version_map)
    assert increment_type == "MAJOR"
def test_find_increment_type_patch_sve():
    messages = PATCH_INCREMENTS_SVE
    increment_type = bump.find_increment(messages,
                                         regex=semantic_version_pattern,
                                         increments_map=semantic_version_map)
    assert increment_type == "PATCH"
def test_find_increment_type_major():
    messages = MAJOR_INCREMENTS_CC
    increment_type = bump.find_increment(messages)
    assert increment_type == "MAJOR"
def test_find_increment_type_patch():
    messages = PATCH_INCREMENTS_CC
    increment_type = bump.find_increment(messages)
    assert increment_type == "PATCH"
def test_find_increment_type_major():
    messages = MAJOR_INCREMENTS_CC
    commits = [GitCommit(rev="test", title=message) for message in messages]
    increment_type = bump.find_increment(commits)
    assert increment_type == "MAJOR"
def test_find_increment_type_patch():
    messages = PATCH_INCREMENTS_CC
    commits = [GitCommit(rev="test", title=message) for message in messages]
    increment_type = bump.find_increment(commits)
    assert increment_type == "PATCH"