How to use the tsrc.executor function in tsrc

To help you get started, we’ve selected a few tsrc 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 / tsrc / tsrc / workspace / syncer.py View on Github external
import tsrc.executor
import tsrc.git


class BadBranches(tsrc.Error):
    pass


@attr.s(frozen=True)
class RepoAtIncorrectBranchDescription:
    src = attr.ib()  # type: str
    actual = attr.ib()  # type: str
    expected = attr.ib()  # type: str


class Syncer(tsrc.executor.Task[tsrc.Repo]):
    def __init__(self, workspace_path: Path, *, force: bool = False) -> None:
        self.workspace_path = workspace_path
        self.bad_branches = []  # type: List[RepoAtIncorrectBranchDescription]
        self.force = force

    def on_start(self, *, num_items: int) -> None:
        ui.info_1("Synchronizing workspace")

    def on_failure(self, *, num_errors: int) -> None:
        ui.error("Failed to synchronize workspace")

    def display_item(self, repo: tsrc.Repo) -> str:
        return repo.src

    def process(self, index: int, count: int, repo: tsrc.Repo) -> None:
        ui.info_count(index, count, repo.src)
github TankerHQ / tsrc / tsrc / workspace / remote_setter.py View on Github external
from typing import Optional
from path import Path
import cli_ui as ui

import tsrc
import tsrc.executor


class RemoteSetter(tsrc.executor.Task[tsrc.Repo]):
    def __init__(self, workspace_path: Path) -> None:
        self.workspace_path = workspace_path

    def on_start(self, *, num_items: int) -> None:
        ui.info_1("Configuring remotes")

    def on_failure(self, *, num_errors: int) -> None:
        ui.error("Failed to configure remotes")

    def display_item(self, repo: tsrc.Repo) -> str:
        return repo.src

    def process(self, index: int, count: int, repo: tsrc.Repo) -> None:
        try:
            self.try_process_repo(repo)
        except Exception:
github TankerHQ / tsrc / tsrc / workspace / cloner.py View on Github external
import textwrap

from path import Path
import cli_ui as ui

import tsrc
import tsrc.git
import tsrc.executor


class Cloner(tsrc.executor.Task[tsrc.Repo]):
    def __init__(self, workspace_path: Path, *, shallow: bool = False) -> None:
        self.workspace_path = workspace_path
        self.shallow = shallow

    def on_start(self, *, num_items: int) -> None:
        ui.info_2("Cloning missing repos")

    def on_failure(self, *, num_errors: int) -> None:
        ui.error("Failed to clone missing repos")

    def display_item(self, repo: tsrc.Repo) -> str:
        return repo.src

    def check_shallow_with_sha1(self, repo: tsrc.Repo) -> None:
        if not repo.sha1:
            return
github TankerHQ / tsrc / tsrc / workspace / copier.py View on Github external
from typing import NewType, Tuple
import stat

import cli_ui as ui
from path import Path

import tsrc.executor


Copy = NewType("Copy", Tuple[str, str])


class FileCopier(tsrc.executor.Task[Copy]):
    def __init__(self, workspace_path: Path) -> None:
        self.workspace_path = workspace_path

    def on_start(self, *, num_items: int) -> None:
        ui.info_1("Copying files")

    def on_failure(self, *, num_errors: int) -> None:
        ui.error("Failed to perform the following copies:")

    def display_item(self, item: Copy) -> str:
        src, dest = item
        return "%s -> %s" % (src, dest)

    def process(self, index: int, count: int, item: Copy) -> None:
        src, dest = item
        ui.info_count(index, count, src, "->", dest)