Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _handle_remotes(self, repo_config: Any) -> List[tsrc.Remote]:
remotes_config = repo_config.get("remotes")
res = [] # type: List[tsrc.Remote]
if remotes_config:
for remote_config in remotes_config:
remote = tsrc.Remote(
name=remote_config["name"], url=remote_config["url"]
)
res.append(remote)
return res
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)
def _handle_repo(self, repo_config: Any) -> None:
src = repo_config["src"]
branch = repo_config.get("branch", "master")
tag = repo_config.get("tag")
sha1 = repo_config.get("sha1")
url = repo_config.get("url")
if url:
origin = tsrc.Remote(name="origin", url=url)
remotes = [origin]
else:
remotes = self._handle_remotes(repo_config)
repo = tsrc.Repo(src=src, branch=branch, sha1=sha1, tag=tag, remotes=remotes)
self._repos.append(repo)