How to use the tsrc.git.get_current_branch 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
def check_branch(self, repo: tsrc.Repo, repo_path: Path) -> None:
        current_branch = None
        try:
            current_branch = tsrc.git.get_current_branch(repo_path)
        except tsrc.Error:
            raise tsrc.Error("Not on any branch")

        if current_branch and current_branch != repo.branch:
            self.bad_branches.append(
                RepoAtIncorrectBranchDescription(
                    src=repo.src, actual=current_branch, expected=repo.branch
                )
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":