How to use the tsrc.git.run_captured 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 / remote_setter.py View on Github external
def get_remote(self, repo: tsrc.Repo, name: str) -> Optional[tsrc.Remote]:
        full_path = self.workspace_path / repo.src
        rc, url = tsrc.git.run_captured(
            full_path, "remote", "get-url", name, check=False
        )
        if rc != 0:
            return None
        else:
            return tsrc.Remote(name=name, url=url)
github TankerHQ / tsrc / tsrc / cli / push.py View on Github external
def read(cls, working_path: Path, *, workspace: tsrc.Workspace) -> "RepositoryInfo":
        repo_path = tsrc.git.get_repo_root(working_path=working_path)
        current_branch = tsrc.git.get_current_branch(repo_path)
        tracking_ref = tsrc.git.get_tracking_ref(repo_path)

        # TODO: we should know the name of the remote at this point,
        # no need to hard-code 'origin'!
        rc, out = tsrc.git.run_captured(
            repo_path, "remote", "get-url", "origin", check=False
        )
        if rc == 0:
            url = out
        if not url:
            raise NoRemoteConfigured(repo_path, "origin")

        project_name = project_name_from_url(url)
        service = service_from_url(url=url, workspace=workspace)

        if service == "gitlab":
            repository_login_url = workspace.get_gitlab_url()
        elif service == "github_enterprise":
            repository_login_url = workspace.get_github_enterprise_url()
        else:
            repository_login_url = None
github TankerHQ / tsrc / tsrc / cli / log.py View on Github external
def main(args: argparse.Namespace) -> None:
    workspace = tsrc.cli.get_workspace(args)
    all_ok = True
    for unused_index, repo, full_path in workspace.enumerate_repos():
        colors = ["green", "reset", "yellow", "reset", "bold blue", "reset"]
        log_format = "%m {}%h{} - {}%d{} %s {}<%an>{}"
        log_format = log_format.format(*("%C({})".format(x) for x in colors))
        cmd = [
            "log",
            "--color=always",
            "--pretty=format:%s" % log_format,
            "%s...%s" % (args.from_, args.to),
        ]
        rc, out = tsrc.git.run_captured(full_path, *cmd, check=False)
        if rc != 0:
            all_ok = False
        if out:
            ui.info(ui.bold, repo.src)
            ui.info(ui.bold, "-" * len(repo.src))
            ui.info(out)
    if not all_ok:
        raise tsrc.Error()