helpers

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package helpers provides utility functions for normalising and manipulating Git references.

Index

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

func NewNoopLogger() *slog.Logger

NewNoopLogger creates and returns a no-operation logger that discards all log output.

func NormaliseFullRef

func NormaliseFullRef[S string | *string](ref S) string

NormaliseFullRef returns a fully qualified Git reference string by prefixing "refs/heads/" to the normalized input reference.

func NormaliseFullRefPtr

func NormaliseFullRefPtr[S string | *string](ref S) *string

NormaliseFullRefPtr returns a normalized full Git reference as a string pointer from the given string or string pointer.

func NormaliseRef

func NormaliseRef[S string | *string](ref S) string

NormaliseRef removes the "refs/heads/" prefix from a Git reference string, handling both string and *string input types.

func NormaliseRefPtr

func NormaliseRefPtr[S string | *string](ref S) *string

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.

func String

func String(p *string) string

String returns the dereferenced value of the input pointer if it's not nil, otherwise, it returns an empty string.

func Truncate

func Truncate(s string, n int) string

Truncate shortens the given string to the specified length, appending "..." if truncation occurs.

Types

type PropertyType

type PropertyType interface {
	string | bool | []string
}

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).

Jump to

Keyboard shortcuts

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