How to use the tbump.action.Action 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 / git_bumper.py View on Github external
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:
        tbump.git.print_git_command(self.cmd)

    def do(self) -> None:
        self.run()

    def run(self) -> None:
        full_args = [self.repo_path] + self.cmd
        return tbump.git.run_git(*full_args, verbose=False)
github TankerHQ / tbump / tbump / file_bumper.py View on Github external
import tbump
import tbump.action
import tbump.git
import tbump.config


@attr.s
class ChangeRequest:
    src = attr.ib()  # type: str
    old_string = attr.ib()  # type: str
    new_string = attr.ib()  # type: str
    search = attr.ib(default=None)  # type: Optional[str]


class Patch(tbump.action.Action):
    def __init__(
        self, working_path: Path, src: str, lineno: int, old_line: str, new_line: str
    ):
        super().__init__()
        self.working_path = working_path
        self.src = src
        self.lineno = lineno
        self.old_line = old_line
        self.new_line = new_line

    def print_self(self) -> None:
        # fmt: off
        ui.info(
            ui.red, "- ", ui.reset,
            ui.bold, self.src, ":", ui.reset,
            ui.darkgray, self.lineno + 1, ui.reset,
github TankerHQ / tbump / tbump / hooks.py View on Github external
from typing import List, Optional  # noqa
import subprocess

from path import Path
import cli_ui as ui

import tbump
import tbump.action


class Hook(tbump.action.Action):
    def __init__(self, name: str, cmd: str):
        super().__init__()
        self.working_path = None  # type: Optional[Path]
        self.name = name
        self.cmd = cmd

    def print_self(self) -> None:
        ui.info(ui.darkgray, "$", ui.reset, self.cmd)

    def do(self) -> None:
        self.run()

    def run(self) -> None:
        rc = subprocess.call(self.cmd, shell=True, cwd=self.working_path)
        if rc != 0:
            raise HookError(name=self.name, cmd=self.cmd, rc=rc)