| 1 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | |
| 3 | // Package repos owns repository creation, validation, and identity. It |
| 4 | // sits above sqlc-generated reposdb queries and orchestrates the |
| 5 | // DB + filesystem dance that produces a usable bare repo. The git |
| 6 | // plumbing helpers used to build the optional initial commit live in |
| 7 | // internal/repos/git. |
| 8 | package repos |
| 9 | |
| 10 | import "errors" |
| 11 | |
| 12 | // User-facing errors. Handlers map these to friendly UI strings; lower |
| 13 | // layers wrap them with %w so handlers can errors.Is for routing. |
| 14 | var ( |
| 15 | // ErrInvalidName is returned when the requested repo name fails the |
| 16 | // shape whitelist (length, characters, edges, dot-dot, etc.). |
| 17 | ErrInvalidName = errors.New("repos: invalid name") |
| 18 | |
| 19 | // ErrReservedName is returned when the name is on the reserved list. |
| 20 | // Distinguished from ErrInvalidName so the UI can say "reserved" vs |
| 21 | // "format" — they're different fixes for the user. |
| 22 | ErrReservedName = errors.New("repos: reserved name") |
| 23 | |
| 24 | // ErrTaken is returned when an active repo (deleted_at IS NULL) |
| 25 | // already exists for this owner with the same name. Surfaces as |
| 26 | // either the explicit pre-check OR the unique-constraint error. |
| 27 | ErrTaken = errors.New("repos: name taken for owner") |
| 28 | |
| 29 | // ErrNoVerifiedEmail is returned when the user has no verified |
| 30 | // primary email. We refuse rather than fabricate an author identity. |
| 31 | ErrNoVerifiedEmail = errors.New("repos: no verified primary email") |
| 32 | |
| 33 | // ErrUnknownLicense / ErrUnknownGitignore — picker chose a key not |
| 34 | // in our curated set. |
| 35 | ErrUnknownLicense = errors.New("repos: unknown license key") |
| 36 | ErrUnknownGitignore = errors.New("repos: unknown gitignore key") |
| 37 | |
| 38 | // ErrDescriptionTooLong mirrors the DB CHECK on description (≤350). |
| 39 | ErrDescriptionTooLong = errors.New("repos: description too long") |
| 40 | ) |
| 41 |