Documentation
¶
Overview ¶
Package helpers provides utility functions for normalising and manipulating Git references.
Index ¶
- func GetCustomProperty[PT PropertyType](props map[string]any, key string) PT
- func NewNoopLogger() *slog.Logger
- func NormaliseFullRef[S string | *string](ref S) string
- func NormaliseFullRefPtr[S string | *string](ref S) *string
- func NormaliseRef[S string | *string](ref S) string
- func NormaliseRefPtr[S string | *string](ref S) *string
- func Ptr[T any](v T) *T
- func RespondHTTP(rw http.ResponseWriter, response models.Response, err error)
- func String(p *string) string
- func Truncate(s string, n int) string
- type PropertyType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCustomProperty ¶
func GetCustomProperty[PT PropertyType](props map[string]any, key string) PT
GetCustomProperty retrieves a repository custom property and coerces it to the requested type. Custom properties arrive from GitHub webhooks decoded into map[string]any, where single/single_select/true_false values are strings and multi_select values are JSON arrays (decoded as []any). Missing keys or values that cannot be coerced yield the zero value of the requested type.
func NewNoopLogger ¶
NewNoopLogger creates and returns a no-operation logger that discards all log output.
func NormaliseFullRef ¶
NormaliseFullRef returns a fully qualified Git reference string by prefixing "refs/heads/" to the normalized input reference.
func NormaliseFullRefPtr ¶
NormaliseFullRefPtr returns a normalized full Git reference as a string pointer from the given string or string pointer.
func NormaliseRef ¶
NormaliseRef removes the "refs/heads/" prefix from a Git reference string, handling both string and *string input types.
func NormaliseRefPtr ¶
NormaliseRefPtr is a helper function that normalizes a Git reference and returns a pointer to the resulting string.
func Ptr ¶
func Ptr[T any](v T) *T
Ptr returns a pointer to the value passed as an argument. If the value is nil, it returns a nil pointer.
func RespondHTTP ¶
func RespondHTTP(rw http.ResponseWriter, response models.Response, err error)
RespondHTTP writes the response to the http.ResponseWriter.
Types ¶
type PropertyType ¶
PropertyType is an interface that represents the supported repository custom property value shapes: a single value (string), a true_false flag (bool), or a multi_select list ([]string).