Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/mdbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- [`assert_lefthook_installed`](./configuration/assert_lefthook_installed.md)
- [`colors`](./configuration/colors.md)
- [`extends`](./configuration/extends.md)
- [`install_non_git_hooks`](./configuration/install_non_git_hooks.md)
- [`lefthook`](./configuration/lefthook.md)
- [`min_version`](./configuration/min_version.md)
- [`no_auto_install`](./configuration/no_auto_install.md)
Expand Down
5 changes: 5 additions & 0 deletions docs/mdbook/configuration/install_non_git_hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## `install_non_git_hooks`

> Since lefthook 2.0.17

Install non-Git hooks into `.git/hooks`. May be useful for using with tools like https://git-flow.sh/.
2 changes: 1 addition & 1 deletion internal/command/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (l *Lefthook) createHooksIfNeeded(cfg *config.Config, hooks []string, force
return fmt.Errorf("could not replace the hook: %w", err)
}

if _, ok := config.AvailableHooks[hook]; !ok {
if _, ok := config.AvailableHooks[hook]; !ok && !cfg.InstallNonGitHooks {
continue
}

Expand Down
24 changes: 24 additions & 0 deletions internal/command/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ post-commit:
hookPath(config.GhostHookName),
},
},
{
name: "with non-git hook",
config: `
test:
jobs:
- run: echo test
`,
wantNotExist: []string{
hookPath("test"),
},
},
{
name: "with non-git hook",
config: `
install_non_git_hooks: true

test:
jobs:
- run: echo test
`,
wantExist: []string{
hookPath("test"),
},
},
{
name: "with existing hooks",
config: `
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Config struct {

NoAutoInstall bool `json:"no_auto_install,omitempty" jsonschema:"description=Do not automatically install hooks when running lefthook" koanf:"no_auto_install" mapstructure:"no_auto_install,omitempty"`

InstallNonGitHooks bool `json:"install_non_git_hooks,omitempty" jsonschema:"description=Install non-Git hooks to .git/hooks" koanf:"install_non_git_hooks" mapstructure:"install_non_git_hooks,omitempty"`

GlobMatcher string `json:"glob_matcher,omitempty" jsonschema:"description=Choose the glob matching engine: 'gobwas' (default) or 'doublestar' (standard ** behavior),enum=gobwas,enum=doublestar,default=gobwas" koanf:"glob_matcher" mapstructure:"glob_matcher,omitempty"`

Remotes []*Remote `json:"remotes,omitempty" jsonschema:"description=Provide multiple remote configs to use lefthook configurations shared across projects. Lefthook will automatically download and merge configurations into main config." mapstructure:"remotes,omitempty"`
Expand Down
6 changes: 5 additions & 1 deletion internal/config/jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
"type": "object"
}
},
"$comment": "Last updated on 2026.01.27.",
"$comment": "Last updated on 2026.02.02.",
"properties": {
"min_version": {
"type": "string",
Expand Down Expand Up @@ -542,6 +542,10 @@
"type": "boolean",
"description": "Do not automatically install hooks when running lefthook"
},
"install_non_git_hooks": {
"type": "boolean",
"description": "Install non-Git hooks to .git/hooks"
},
"glob_matcher": {
"type": "string",
"enum": [
Expand Down
6 changes: 5 additions & 1 deletion schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
"type": "object"
}
},
"$comment": "Last updated on 2026.01.27.",
"$comment": "Last updated on 2026.02.02.",
"properties": {
"min_version": {
"type": "string",
Expand Down Expand Up @@ -542,6 +542,10 @@
"type": "boolean",
"description": "Do not automatically install hooks when running lefthook"
},
"install_non_git_hooks": {
"type": "boolean",
"description": "Install non-Git hooks to .git/hooks"
},
"glob_matcher": {
"type": "string",
"enum": [
Expand Down
Loading