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

Function safe_repo_name

scripts/rag_scraper.py:72–77  ·  view source on GitHub ↗
(url: str)

Source from the content-addressed store, hash-verified

70
71
72def safe_repo_name(url: str) -> str:
73 if os.path.exists(url):
74 return Path(url).resolve().name
75 clean = url.rstrip("/").removesuffix(".git")
76 parts = clean.split("/")[-2:]
77 return "__".join(parts) if len(parts) == 2 else hashlib.sha1(url.encode()).hexdigest()[:12]
78
79
80def ensure_repo(spec: RepoSpec, cache_dir: Path) -> Path:

Callers 2

ensure_repoFunction · 0.85
scrape_repoFunction · 0.85

Calls 1

existsMethod · 0.45

Tested by

no test coverage detected