Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def sync_repo_to_ref(repo_path: Path, ref: str) -> None:
ui.info_2("Resetting to", ref)
status = tsrc.git.get_status(repo_path)
if status.dirty:
raise tsrc.Error("%s is dirty, skipping" % repo_path)
try:
tsrc.git.run(repo_path, "reset", "--hard", ref)
except tsrc.Error:
raise tsrc.Error("updating ref failed")
def get_details(location: Path) -> str:
# Maybe we are importing from a wheel or an egg:
if not location.isdir():
return ""
# Maybe we are not in a git repo:
try:
status = tsrc.git.get_status(location)
except tsrc.git.CommandError:
return ""
res = " - git: %s" % status.sha1
if status.dirty:
res += " (dirty)"
return res
def process(self, index: int, total: int, repo: tsrc.Repo) -> None:
ui.info_count(index, total, repo.src, end="\r")
full_path = self.workspace_path / repo.src
if not full_path.exists():
self.statuses[repo.src] = tsrc.errors.MissingRepo(repo.src)
return
try:
self.statuses[repo.src] = tsrc.git.get_status(full_path)
except Exception as e:
self.statuses[repo.src] = e
erase_last_line()