Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / Source

Match a repository reference

Accepts an id, a canonical URL, a name or a URL suffix.

PINNED SOURCE Copied from the repository at this commit. Source, not an execution.

PHAROS at 975a38dMIT license

repositories_matchingbackend/app/codeintel/retrieval.py, lines 614–630Open source
def repositories_matching(db: Session, ref: str | None) -> list[Repository]:    """Resolve a repository reference: id, canonical URL, name or URL suffix."""    if not ref:        return []    ref = ref.strip()    try:        rid = uuid.UUID(ref)        repo = db.get(Repository, rid)        return [repo] if repo else []    except ValueError:        pass    norm = ref.lower().removesuffix(".git").rstrip("/")    repos = db.execute(select(Repository)).scalars().all()    exact = [r for r in repos if r.url.lower() == norm or r.name.lower() == norm]    if exact:        return exact    return [r for r in repos if r.url.lower().endswith("/" + norm) or r.name.lower().endswith("/" + norm)]

Where this comes from

Commit
975a38d5d17839c26ee219295a5be6ac66b6d910
File
backend/app/codeintel/retrieval.py
Lines
614–630
Git blob
884729a39ae0b3d340ad83f75946677dcddf3791
License
MIT, © 2024–2026 Pharos Contributors. Notice

Read it on GitHub at this commit

Check it yourself

From a clone of the repository, the first command prints the blob above and the second prints these lines.

git rev-parse 975a38d:backend/app/codeintel/retrieval.py
git show 975a38d:backend/app/codeintel/retrieval.py | sed -n '614,630p'