Documentation
¶
Overview ¶
Package pluginutil collects the small input-parsing and formatting helpers that nearly every plugin reimplements verbatim. Keep this file the single source of truth for those primitives so the per- plugin _.go files stay focused on their domain logic.
Index ¶
- Constants
- func ExtrasEnabled(in map[string]any, key string) bool
- func IsZeroSHA(sha string) bool
- func LoginFromInputs(in map[string]any) string
- func Plural(n int) string
- func ReadBool(in map[string]any, key string) bool
- func ReadBoolDefault(in map[string]any, key string, def bool) bool
- func ReadCSV(in map[string]any, key string) []string
- func ReadCSVValue(v any) []string
- func ReadInt(in map[string]any, key string) (int, bool)
- func ReadIntDefault(in map[string]any, key string, def int) int
- func TrimEmpty(in []string) []string
- func Truthy(v any) bool
- func TruthyInput(in map[string]any, key string) bool
Constants ¶
const ZeroSHA = "0000000000000000000000000000000000000000"
ZeroSHA is the all-zero git object id GitHub returns on the create- branch "before" / delete-branch "after" sides of a PushEvent.
Variables ¶
This section is empty.
Functions ¶
func ExtrasEnabled ¶
ExtrasEnabled gates a "show by default unless the user explicitly turned it off" toggle. Missing key (or nil map) means enabled.
func IsZeroSHA ¶
IsZeroSHA reports whether sha is empty or the all-zero git OID (transient create/delete markers in events).
func LoginFromInputs ¶
LoginFromInputs returns the GitHub login the plugin should act on: `user` first, then the upstream alias `login`. nil map returns "".
func Plural ¶
Plural mirrors upstream's `s()` template helper: returns "" when n is 1, "s" otherwise. Use for English-style "1 commit" / "2 commits" labels.
func ReadBool ¶
ReadBool parses in[key] into a bool via the same rules as Truthy. Missing/unparsable returns false.
func ReadBoolDefault ¶
ReadBoolDefault parses in[key] into a bool. Missing key returns def; a present but unparsable value also returns def (mirrors the legacy per-plugin behavior — a literal "off"/"no" string evaluates as !Truthy and therefore yields def, which matches upstream's "any unrecognized value means default" semantics).
func ReadCSV ¶
ReadCSV parses in[key] as a comma-separated list. Accepts []string, []any, and string. Empty/whitespace-only entries are dropped.
func ReadCSVValue ¶
ReadCSVValue is ReadCSV's single-value form, for callers that have already pulled the value out of the map (or get it from elsewhere).
func ReadInt ¶
ReadInt parses in[key] into an int, accepting Go ints, int64, float64 (the YAML loader's default for numerics), and base-10 strings.
func ReadIntDefault ¶
ReadIntDefault returns ReadInt's value or def when the key is missing or unparsable.
func TrimEmpty ¶
TrimEmpty strips leading/trailing whitespace from each entry and drops the ones that collapse to empty.
func Truthy ¶
Truthy collapses the input-map's any to a bool. Accepts bool, the strings "true"/"1"/"yes" (case-insensitive, whitespace-trimmed), and non-zero numerics. Mirrors upstream metadata.mjs's `descriptor.type === "boolean"` parsing — the action YAML loader normalizes bools, but tests and direct callers may still pass raw strings.
Types ¶
This section is empty.