Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
)
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":