Documentation
¶
Overview ¶
Package gitrepo maps a repository name received from a git client to a bare repository on disk, decides who may read it, and bounds how many fetches run at once. SSH and smart HTTP both go through it, so they refuse the same names and apply the same rule.
Repositories live at <root>/<owner>/<name>.git. Until milestone 4 (push) they are created outside the forge with `git init --bare`. There is no ACL yet: an account reads its own repositories, and anyone reads one that holds the file git-daemon-export-ok (git's own "public" marker, honoured by git daemon and http-backend).
Index ¶
Constants ¶
const ( DefaultTotalSessions = 64 DefaultSessionsPerKey = 4 DefaultRequestDuration = 15 * time.Minute )
Defaults for the caps and the time one request may take.
const PublicMarker = "git-daemon-export-ok"
PublicMarker is the file whose presence in a repository makes it public.
Variables ¶
var ErrBusy = errors.New("too many concurrent git sessions")
ErrBusy is returned when a concurrency cap is reached.
var ErrNotFound = errors.New("repository not found")
ErrNotFound is returned for a repository that does not exist and for one the caller may not read: the two are indistinguishable on purpose, so a name cannot be probed.
var ErrPath = errors.New("invalid repository path")
ErrPath is returned for a path that is not owner/name.
Functions ¶
func WithTimeout ¶
WithTimeout derives the context a request runs under.
Types ¶
type Limiter ¶
type Limiter struct {
Total, PerKey int
// contains filtered or unexported fields
}
Limiter caps concurrent sessions in total and per key (an account, or a remote host). A session over a cap is refused at once, not queued: waiting would let idle sessions hold everyone else out.
type Name ¶
type Name struct{ Owner, Repo string }
Name identifies a repository.
type Service ¶
type Service struct {
// Root is the directory holding <owner>/<name>.git.
Root string
// Git is the git executable ("" for the one on PATH).
Git string
// Limits bound one protocol request (zero fields mean gitproto's defaults).
Limits gitproto.Limits
// PackThreads is passed to pack-objects (0: git's default).
PackThreads int
// Agent is advertised to clients ("" for gitproto's).
Agent string
// Collaborator, if set, tells whether login is a collaborator of n: a
// collaborator reads a private repository like its owner does.
Collaborator func(n Name, login string) bool
}
Service opens repositories under Root.
func (*Service) Dir ¶
Dir returns the directory of the bare repository n if login may read it, with the rule of Open (the web pages and the protocols read the same repositories).