pluginutil

package
v1.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func ExtrasEnabled(in map[string]any, key string) bool

ExtrasEnabled gates a "show by default unless the user explicitly turned it off" toggle. Missing key (or nil map) means enabled.

func IsZeroSHA

func IsZeroSHA(sha string) bool

IsZeroSHA reports whether sha is empty or the all-zero git OID (transient create/delete markers in events).

func LoginFromInputs

func LoginFromInputs(in map[string]any) string

LoginFromInputs returns the GitHub login the plugin should act on: `user` first, then the upstream alias `login`. nil map returns "".

func Plural

func Plural(n int) string

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

func ReadBool(in map[string]any, key string) bool

ReadBool parses in[key] into a bool via the same rules as Truthy. Missing/unparsable returns false.

func ReadBoolDefault

func ReadBoolDefault(in map[string]any, key string, def bool) bool

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

func ReadCSV(in map[string]any, key string) []string

ReadCSV parses in[key] as a comma-separated list. Accepts []string, []any, and string. Empty/whitespace-only entries are dropped.

func ReadCSVValue

func ReadCSVValue(v any) []string

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

func ReadInt(in map[string]any, key string) (int, bool)

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

func ReadIntDefault(in map[string]any, key string, def int) int

ReadIntDefault returns ReadInt's value or def when the key is missing or unparsable.

func TrimEmpty

func TrimEmpty(in []string) []string

TrimEmpty strips leading/trailing whitespace from each entry and drops the ones that collapse to empty.

func Truthy

func Truthy(v any) bool

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.

func TruthyInput

func TruthyInput(in map[string]any, key string) bool

TruthyInput is Truthy applied to in[key]. A nil map or missing key returns false.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL