Expand description
The JSON API read surface and repo metadata edit.
Dispatches the /api/repos, /api/repos/<owner>, /api/repos/<owner>/<repo>
and /api/repos/<owner>/<repo>/{tree,blob,commits,commit} routes. Shapes
follow the JSS forge JSON API (apiRepoList, apiRepoMeta, apiTree,
apiBlob, apiCommits, apiCommit, apiRepoPatch), cited by name only.
Strings are raw (JSON is the escape); the one exception is readme.html,
which is the already-escaped output of crate::markdown.
Every ref and path is validated with crate::guard before it reaches a
git argv, and git is only ever run through crate::gitrun.
Structs§
- RefRow
- A parsed git ref listing row.
- Repo
Summary - Repository summary used by the list endpoints and the HTML index.
- TreeRow
- One
ls-tree -lrow.
Constants§
- DESCRIPTION_
CAP - Repo description cap (JSS
DESCRIPTION_CAP). - JSON_
BODY_ CAP - Body cap for JSON writes (JSS
ISSUE_BODY_CAP + 8192). - PER_
PAGE - Commits per page (JSS
PER_PAGE). - RENDER_
CAP - Blobs and READMEs above this are “view raw” (JSS
RENDER_CAP).
Functions§
- api_err
- A JSON
{ "error": msg }response (JSSapiErr). - is_read
- Is the method a read (
GET/HEAD)? - is_
readme_ name ^readme(\.(md|markdown|txt))?$, case-insensitive.- json_
resp - A JSON response with the JSS
sendJsonheaders. - last_
commit - Last commit touching
path(or the ref tip when empty). - list_
refs for-each-refoverrefs/headsorrefs/tags, newest first.- looks_
binary - Does
scontain a NUL in its first 8000 bytes (git’s binary heuristic)? - ls_tree
ls-tree -z -l <ref>[:path], directories first.- read_
json_ body - Parse the request body as a JSON object (JSS
readJsonBody):Nonewhen empty, oversized, unparseable or not an object. - repo_
description - Description: git’s
descriptionfile when customised, else the README first line. - split_
ref_ path - Longest ref-name match wins (JSS
splitRefPath):["feature","x","src"]becomes("feature/x", ["src"])whenfeature/xis a branch or tag. - unauthorised
401with the JSSWWW-Authenticate: Bearerchallenge.