MCPcopy Index your code
hub / github.com/Doorman11991/smallcode / ensure_repo

Function ensure_repo

scripts/rag_scraper.py:80–89  ·  view source on GitHub ↗
(spec: RepoSpec, cache_dir: Path)

Source from the content-addressed store, hash-verified

78
79
80def ensure_repo(spec: RepoSpec, cache_dir: Path) -> Path:
81 if os.path.isdir(spec.url) and not spec.url.startswith(("http://", "https://", "git@")):
82 return Path(spec.url).resolve()
83 cache_dir.mkdir(parents=True, exist_ok=True)
84 dest = cache_dir / safe_repo_name(spec.url)
85 if (dest / ".git").exists():
86 run_git(["pull", "--ff-only"], dest)
87 else:
88 run_git(["clone", "--depth=1", "--filter=blob:none", spec.url, str(dest)], cache_dir)
89 return dest
90
91
92def iter_code_files(root: Path, max_bytes: int, languages: Optional[set[str]]) -> Iterator[Tuple[Path, str]]:

Callers 1

mainFunction · 0.85

Calls 3

safe_repo_nameFunction · 0.85
run_gitFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected