Skip to main content

Module labels

Module labels 

Source
Expand description

Issue (and pull request) labels: GitHub’s default set, owner-only CRUD, per-item assignment, list filtering, rename / delete cascades and the luminance-aware chip helpers.

Follows the JSS forge behaviour (labelDefs, ensureLabels, resolveLabels, apiLabel*, apiItemLabels, labelTextColor, labelChips), cited by name only. The per-repo label set lives in the issue index file (crate::spine::issues::IssueIndex::labels); the defaults apply until the first label write materialises them. Items store label names, so a recolour needs no cascade; rename and delete cascade over issues and pulls.

§Reuse by pull requests

Pull requests keep their own index (pulls/<owner>/<repo>.json, kind PULLS_KIND) whose items carry a labels name array. The cascade and the PUT …/labels handler therefore work on that file as raw JSON, with no dependency on a pull-request type: a pull-request route only has to call ForgeService::put_item_labels with ItemKind::Pull, and the label CRUD routes already keep pull labels consistent. Pull writes take crate::locks::ForgeLocks::pulls after the issue lock.

Enums§

ItemKind
Which index an item label operation targets.

Constants§

DEFAULT_LABELS
GitHub’s default label set, in JSS order.
LABELS_PER_ITEM
Most labels one item may carry.
PULLS_KIND
Spine kind of the pull-request index.

Functions§

chips_html
Rounded chips for resolved labels (everything escaped; the colour is re-validated so a corrupt index cannot inject into the style attribute).
default_labels
The default set as Labels.
effective_labels
The effective label set: the materialised one, or the defaults.
ensure_labels
First label write materialises the defaults into the index.
remove_from
Drop name from a name list; true when something changed.
rename_in
Rename old to new in a name list; true when something changed.
resolve_labels
Item label names to {name, color} against defs; a name with no definition keeps the neutral ededed.
text_color
Perceptual-luminance text colour for a chip (GitHub style): dark text on bright backgrounds, white on dark ones. hex must be six hex digits.
valid_label_color
Exactly six hex digits.
valid_label_name
1 to 50 characters, none of them control characters.