How to use the tbump.git.GitError function in tbump

To help you get started, we’ve selected a few tbump examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TankerHQ / tbump / tbump / main.py View on Github external
# fmt: off
    ui.info_1(
        "Bumping from", ui.bold, config.current_version,
        ui.reset, "to", ui.bold, new_version,
    )
    # fmt: on

    git_bumper = GitBumper(working_path)
    git_bumper.set_config(config)
    git_state_error = None
    try:
        git_bumper.check_dirty()  # Avoid data loss
        if not only_patch:
            git_bumper.check_branch_state(new_version)
    except tbump.git.GitError as e:
        if dry_run:
            git_state_error = e
        else:
            raise

    file_bumper = FileBumper(working_path)
    file_bumper.set_config(config)

    hooks_runner = HooksRunner(working_path, config.current_version)
    if not only_patch:
        for hook in config.hooks:
            hooks_runner.add_hook(hook)

    executor = Executor(new_version, file_bumper)
    if not only_patch:
        executor.add_git_and_hook_actions(new_version, git_bumper, hooks_runner)
github TankerHQ / tbump / tbump / git_bumper.py View on Github external
def print_error(self) -> None:
        ui.error("Not on any branch")


class NoTrackedBranch(tbump.git.GitError):
    def __init__(self, *, branch: str):
        super().__init__()
        self.branch = branch

    def print_error(self) -> None:
        ui.error(
            "Current branch (%s)" % self.branch, "does not track anything. Cannot push."
        )


class RefAlreadyExists(tbump.git.GitError):
    def __init__(self, *, ref: str):
        super().__init__()
        self.ref = ref

    def print_error(self) -> None:
        ui.error("git ref", self.ref, "already exists")


class Command(tbump.action.Action):
    def __init__(self, repo_path: Path, cmd: List[str]):
        super().__init__()
        self.repo_path = repo_path
        self.cmd = list(cmd)
        self.verbose = True

    def print_self(self) -> None:
github TankerHQ / tbump / tbump / git.py View on Github external
from typing import List, Optional, Tuple
import subprocess

from path import Path
import cli_ui as ui

import tbump


class GitError(tbump.Error):
    pass


class GitCommandError(GitError):
    def __init__(
        self, cmd: List[str], working_path: Path, output: Optional[str] = None
    ):
        super().__init__()
        self.cmd = cmd
        self.output = output
        self.working_path = working_path

    def print_error(self) -> None:
        cmd_str = " ".join(self.cmd)
        ui.error("Command", "`%s`" % cmd_str, "failed")


def print_git_command(cmd: List[str]) -> None:
    ui.info(ui.darkgray, "$", ui.reset, "git", *cmd)
github TankerHQ / tbump / tbump / git_bumper.py View on Github external
from typing import List, Tuple
from path import Path
import cli_ui as ui

import tbump.action
from tbump.config import Config
import tbump.git


class DirtyRepository(tbump.git.GitError):
    def __init__(self, *, git_status_output: str):
        super().__init__()
        self.git_status_output = git_status_output

    def print_error(self) -> None:
        ui.error("Repository is dirty")
        ui.info(self.git_status_output)


class NotOnAnyBranch(tbump.git.GitError):
    def print_error(self) -> None:
        ui.error("Not on any branch")


class NoTrackedBranch(tbump.git.GitError):
    def __init__(self, *, branch: str):
github TankerHQ / tbump / tbump / git_bumper.py View on Github external
class DirtyRepository(tbump.git.GitError):
    def __init__(self, *, git_status_output: str):
        super().__init__()
        self.git_status_output = git_status_output

    def print_error(self) -> None:
        ui.error("Repository is dirty")
        ui.info(self.git_status_output)


class NotOnAnyBranch(tbump.git.GitError):
    def print_error(self) -> None:
        ui.error("Not on any branch")


class NoTrackedBranch(tbump.git.GitError):
    def __init__(self, *, branch: str):
        super().__init__()
        self.branch = branch

    def print_error(self) -> None:
        ui.error(
            "Current branch (%s)" % self.branch, "does not track anything. Cannot push."
        )


class RefAlreadyExists(tbump.git.GitError):
    def __init__(self, *, ref: str):
        super().__init__()
        self.ref = ref

    def print_error(self) -> None:
github TankerHQ / tbump / tbump / git_bumper.py View on Github external
import tbump.action
from tbump.config import Config
import tbump.git


class DirtyRepository(tbump.git.GitError):
    def __init__(self, *, git_status_output: str):
        super().__init__()
        self.git_status_output = git_status_output

    def print_error(self) -> None:
        ui.error("Repository is dirty")
        ui.info(self.git_status_output)


class NotOnAnyBranch(tbump.git.GitError):
    def print_error(self) -> None:
        ui.error("Not on any branch")


class NoTrackedBranch(tbump.git.GitError):
    def __init__(self, *, branch: str):
        super().__init__()
        self.branch = branch

    def print_error(self) -> None:
        ui.error(
            "Current branch (%s)" % self.branch, "does not track anything. Cannot push."
        )


class RefAlreadyExists(tbump.git.GitError):