gitlab-org/gitlab
Repository
Repository (app/models/repository.rb) is the Ruby-side handle to a Gitaly-backed Git repository. Every project, snippet, and wiki has one.
Source
app/models/repository.rb— high-level facade.lib/gitlab/git/repository.rb— lower-level wrapper around the Gitaly client.lib/gitlab/gitaly_client/<service>.rb— gRPC service classes.
What it exposes
project.repository.commit('main')
project.repository.commits('main', limit: 20)
project.repository.tree('main', 'docs/')
project.repository.blob_at('main', 'README.md')
project.repository.protected_branches
project.repository.branches
project.repository.tags
project.repository.languages # cached, expensive
project.repository.size # cached on project_statisticsCaching
Repository extends Gitlab::RepositoryCacheAdapter (lib/gitlab/repository_cache_adapter.rb). Hot reads (tree, commit, branches) cache results in Redis with invalidation on push.
Storage shards
Each repository has a repository_storage (string), pointing to a Gitaly node configured in config/gitlab.yml. Multi-shard installs spread repos across shards.
Object pools
Forks share an "object pool" (a special Gitaly repo) for deduplication. The pool_repository association tracks it.
Repository checks
RepositoryCheckService periodically runs git fsck on repos to detect corruption.
Housekeeping
Projects::HousekeepingService runs git gc/git repack. Triggered via push counters and a cron sweep.
Related
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.