config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2018 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindConfigurationFilePath

func FindConfigurationFilePath() (string, error)

FindConfigurationFilePath searches the git-commit-hook config file in various places and returns the first found filepath or error

Types

type BranchTypePattern

type BranchTypePattern string

BranchTypePattern defines a regex pattern that identifies a branch type

type BranchTypeTemplate

type BranchTypeTemplate string

BranchTypeTemplate holds a go template that defined the modified commit message

type BranchValidationConfiguration

type BranchValidationConfiguration map[string]string

BranchValidationConfiguration holds a regex pattern in the index and a test description in the value of the map The pattern will be tested against a prepared commit message.

type Configuration

type Configuration map[string]Project

Configuration is the data representation of the config file structure

func LoadConfiguration

func LoadConfiguration() (*Configuration, error)

LoadConfiguration loads the git-commit-hook configuration from file.

func (*Configuration) GetProjectByName

func (c *Configuration) GetProjectByName(projectName string) (Project, error)

GetProjectByName returns a Project for the given project name

func (*Configuration) GetProjectByRepoPath

func (c *Configuration) GetProjectByRepoPath(path string) (Project, error)

GetProjectByRepoPath returns a Project for the given git repository path

type Project

type Project struct {
	// Path to the git repository this configuration should be used while committing
	Path string `yaml:"path"`
	// BranchTypes is a map whose key defines a BranchType - it's value holds a pattern that identifies
	// a given branch name to be of that branch type.
	BranchTypes map[string]BranchTypePattern `yaml:"branch"`
	// Templates is a map whose key refers a branchType - it's value holds a go template that will render the commit message
	Templates map[string]BranchTypeTemplate `yaml:"template"`
	// Validation is a map whose key refers a branchType - it's value holds configuration to validate the created commit message
	Validation map[string]BranchValidationConfiguration `yaml:"validation"`
}

Project defined a project related section of the Configuration

func LoadProjectConfigurationByName

func LoadProjectConfigurationByName(projectName string) (Project, error)

LoadProjectConfigurationByName loads a project configuration by its name

func LoadProjectConfigurationFromCommitMessageFileDir

func LoadProjectConfigurationFromCommitMessageFileDir(commitMessageFile string) (Project, error)

LoadProjectConfigurationFromCommitMessageFileDir loads a project configuration by resolving a given commit-message file

func (*Project) GetBranchType

func (projConf *Project) GetBranchType(branchName string) string

GetBranchType returns a branch type for the given branch name or empty string if no branch type was found.

func (*Project) GetValidator

func (projConf *Project) GetValidator(branchType string) map[string]string

GetValidator returns the validator that matches the given branch type if no

Jump to

Keyboard shortcuts

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