helpers

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 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]string, key string) PT

GetCustomProperty is a helper function that retrieves a custom property from a map of string properties.

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
}

PropertyType is an interface that represents a property type that can be either a string or a boolean.

Jump to

Keyboard shortcuts

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