How to use the tsrc.git 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 add_remote(self, repo: tsrc.Repo, remote: tsrc.Remote) -> None:
        full_path = self.workspace_path / repo.src
        # fmt: off
        ui.info_2(repo.src + ":", "Add remote",
                  ui.bold, remote.name, ui.reset,
                  ui.brown, "(%s)" % remote.url)
        # fmt: on
        tsrc.git.run(full_path, "remote", "add", remote.name, remote.url)
github TankerHQ / tsrc / tsrc / workspace / local_manifest.py View on Github external
def _reset_manifest_clone(self, url: str, *, branch: str) -> None:
        tsrc.git.run(self.clone_path, "remote", "set-url", "origin", url)

        tsrc.git.run(self.clone_path, "fetch")
        tsrc.git.run(self.clone_path, "checkout", "-B", branch)
        # fmt: off
        tsrc.git.run(
            self.clone_path, "branch", branch,
            "--set-upstream-to", "origin/%s" % branch
        )
        # fmt: on
        ref = "origin/%s" % branch
        tsrc.git.run(self.clone_path, "reset", "--hard", ref)
github TankerHQ / tsrc / tsrc / cli / push.py View on Github external
def push(self) -> None:
        ui.info_2("Running git push")
        remote_name = self.remote_name or "origin"
        if self.args.push_spec:
            push_spec = self.args.push_spec
        else:
            push_spec = "%s:%s" % (self.current_branch, self.remote_branch)
        cmd = ["push", "-u", remote_name, push_spec]
        if self.args.force:
            cmd.append("--force")
        tsrc.git.run(self.repo_path, *cmd)
github TankerHQ / tsrc / tsrc / workspace / syncer.py View on Github external
def sync_repo_to_branch(repo_path: Path) -> None:
        ui.info_2("Updating branch")
        try:
            tsrc.git.run(repo_path, "merge", "--ff-only", "@{upstream}")
        except tsrc.Error:
            raise tsrc.Error("updating branch failed")
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)