Expand description
Compare: resolve a base and a (possibly cross-fork) head, then report ahead/behind counts, the commit list and a structured diff.
Behaviour follows the JSS forge compareData, resolveHead,
parseHeadSpec, parsePatch and renderDiff (cited by name only). A head
is either a branch of the same repository (feature) or <owner>:<ref>, a
branch of the named owner’s same-named repository. A cross-repository head
is path-fetched into the base repository under the hidden, reusable ref
refs/forge/heads/<owner>/<ref>; both ends of the fetch are forge-owned
paths and no user-supplied URL is ever fetched.
Structs§
- Commit
Summary - One commit in a compare/PR list (JSS
commitLogshape). - Compare
- Everything a compare view needs.
- Diff
File - One file of a structured diff (JSS
parsePatchshape). - Diff
Line - One diff line with its old/new numbers.
- HeadRef
- A resolved compare/PR head.
- Hunk
- One
@@hunk.
Enums§
- Line
Kind - Kind of one diff line.
Constants§
- COMMITS_
PER_ PAGE - Commits per page in compare and pull commit lists (JSS
PER_PAGE).
Functions§
- parse_
head_ spec - Parse
reforowner:refagainst the base owner.Nonewhen invalid. - parse_
patch - Parse unified
git diffoutput into a structured per-file form, as JSSparsePatchdoes. Unlike the JSS parser, hunk bodies are consumed by the line counts in their@@header, so a content line that happens to start with+++or---is classified as content, not as a file header. - render_
diff - Render a structured diff as escaped HTML tables (JSS
renderDiff). - valid_
owner - JSS
OWNER_NAME: alphanumeric first, then[A-Za-z0-9._-], at most 64. - valid_
ref - JSS
okRef: alphanumeric first, then[A-Za-z0-9._/-](at most 201), no.., no//, no trailing/. Additionally refuses a trailing.lockor., which git itself would reject, so a branch name can never address a lock file. A leading-is impossible, so it can never be read as an option. - valid_
repo - JSS
REPO_NAME(at most 128) tightened to the crate’s 100-character directory limit, with no..and no.gitsuffix. - valid_
sha - JSS
SHA_RE: 4 to 64 lowercase hexadecimal characters.