Documentation ¶
Index ¶
Constants ¶
View Source
const ( // BranchPushAction a branch is pushed BranchPushAction = "branch.push" // BranchCreateAction a branch is created BranchCreateAction = "branch.create" // BranchDeleteAction a branch is deleted BranchDeleteAction = "branch.delete" // TagCreateAction a tag is created TagCreateAction = "tag.create" // TagDeleteAction a tag is deleted TagDeleteAction = "tag.delete" // ZeroCommit hash if no commit ZeroCommit = "0000000000000000000000000000000000000000" )
Variables ¶
View Source
var ( // ConfigFilename Git hooks configuration filename to be parsed ConfigFilename = ".githooks.yml" // ErrFileNotFound File not found error ErrFileNotFound = errors.New("configuration file .githooks.(yaml|yml) not found") )
View Source
var ( // ErrNoHookData no hook data error ErrNoHookData = errors.New("Hook data is mandatory") // ErrInvalidHookData invalid hook input ErrInvalidHookData = errors.New("invalid hook input") // HookTypes that are supported by Watchdog HookTypes = [...]string{ "pre-receive", "update", "post-receive", } )
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition struct { Condition string `yaml:"condition"` FailFast string `yaml:"fail_fast"` Ignore bool `yaml:"ignore"` Only []string RejectionMessage string `yaml:"rejection_message"` Skip string `yaml:"skip"` Type ConditionType `yaml:"type"` }
Condition used in hook's rules
type ConditionType ¶
type ConditionType string
ConditionType condition type
const ( // ConditionEmail email condition ConditionEmail ConditionType = "email" // ConditionExtension file extension condition ConditionExtension ConditionType = "extension" // ConditionIP ip condition ConditionIP ConditionType = "ip" // ConditionIssue issue condition ConditionIssue ConditionType = "issue" // ConditionLength length condition ConditionLength ConditionType = "length" // ConditionPattern pattern condition ConditionPattern ConditionType = "pattern" // ConditionProtected protected condition ConditionProtected ConditionType = "protected" // ConditionSecret secret condition ConditionSecret ConditionType = "secret" // ConditionSemVer semver condition ConditionSemVer ConditionType = "semver" // ConditionSignature secret condition ConditionSignature ConditionType = "signature" // ConditionSize file size condition ConditionSize ConditionType = "size" )
type GitHooks ¶
type GitHooks struct { Hooks []Hook `yaml:"hooks,omitempty"` Locked bool `yaml:"locked"` Version string `yaml:"version,omitempty"` }
GitHooks data structure
func ExtractConfigFile ¶
ExtractConfigFile extract .githooks.yml file from Git bare repository
func LoadGitHooks ¶
LoadGitHooks load and return Configuration struct
func LoadGitHooksFromRaw ¶
LoadGitHooksFromRaw load config file from raw data
type HandlerType ¶
type HandlerType string
HandlerType handler type
const ( // TypeBranch constant for branch handler TypeBranch HandlerType = "branch" // TypeCommit constant for commit handler TypeCommit HandlerType = "commit" // TypeFile constant for file handler TypeFile HandlerType = "file" // TypeJira constant for jira handler TypeJira HandlerType = "jira" // TypeSecurity constant for security handler TypeSecurity HandlerType = "security" // TypeTag constant for tag handler TypeTag HandlerType = "tag" )
type Hook ¶
type Hook struct { Description string `yaml:"description"` Name string `yaml:"name,omitempty"` RejectionMessage string `yaml:"rejection_message"` Rules []*Rule `yaml:"rules,omitempty"` }
Hook hook aggregate model
type Info ¶
type Info struct { Action string NewRev *object.Commit // New object name to be stored in the ref. When you delete a ref, this equals 40 zeroes. OldRev *object.Commit // Old object name stored in the ref. When you create a new ref, this equals 40 zeroes. Ref plumbing.ReferenceName // The full name of the ref. RefType string // One of : heads / remotes / tags RepoName string RepoPath string // contains filtered or unexported fields }
Info git hook data structure
type Rule ¶
type Rule struct { Conditions []Condition `yaml:"conditions,omitempty"` Description string `yaml:"description,omitempty"` Disabled bool `yaml:"disabled,omitempty"` Type HandlerType `yaml:"type,omitempty"` }
Rule data structure Use similar mechanism as Gitlab, see https://docs.gitlab.com/ee/push_rules/push_rules.html
Click to show internal directories.
Click to hide internal directories.