hooksscripts

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorScriptAlreadyExists   = errors.New("script already exists")
	ErrorScriptVersionNotFound = errors.New("script version not found")
)

Functions

func AddGookmeScript

func AddGookmeScript(
	content string,
	scriptscriptVariables *ScriptVariables,
) (string, error)

AddGookmeScript adds the gookme script to the provided content

func AssertFile

func AssertFile(path string) error

AssertFile checks if the file at the provided path exists, if not it creates it

func AssertFolder

func AssertFolder(path string) error

AssertFolder checks if the folder at the provided path exists, if not it creates it

func DeleteScriptFile

func DeleteScriptFile(gitFolderPath string, hookName configuration.HookType) error

func GenerateScript

func GenerateScript(variables *ScriptVariables, template string) string

GenerateScript generates a script from a template and the provided variables

func LoadScriptFileContent

func LoadScriptFileContent(gitFolderPath string, hookName configuration.HookType) (string, error)

LoadScriptFileContent loads the content of a file located in the .git folder of the provided directory, and named after the provided hook name.

func ParseScriptVersion

func ParseScriptVersion(content string) (string, error)

ParseScriptVersion Looks for a script in the provided content, and parse it to get the version it has been generated with

func RemoveExistingGookmeScript

func RemoveExistingGookmeScript(
	content string,
) string

RemoveExistingGookmeScript removes the gookme script from the provided content

func ScriptFileExists

func ScriptFileExists(gitFolderPath string, hookName configuration.HookType) (bool, error)

Check if git hook script for the provided hook type exists in the provided directory

func WriteScriptFileContent

func WriteScriptFileContent(gitFolderPath string, hookName configuration.HookType, content string) error

WriteScriptFileContent writes a script in the .git folder, with the provided content and named after the provided hook name.

Types

type ScriptVariables

type ScriptVariables struct {
	HookType configuration.HookType
	Version  string
}

Jump to

Keyboard shortcuts

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