From edba327b7f83d3659d7c4d5760517f02fe662453 Mon Sep 17 00:00:00 2001 From: Eduardo Lorenzo Date: Fri, 6 Mar 2026 08:52:56 +0100 Subject: [PATCH] feat(config): add skip push hooks --- docs-master/Config.md | 3 +++ docs/Config.md | 3 +++ pkg/commands/git_commands/sync.go | 2 ++ pkg/commands/git_commands/sync_test.go | 8 ++++++++ pkg/config/user_config.go | 2 ++ pkg/gui/controllers/sync_controller.go | 1 + schema-master/config.json | 5 +++++ 7 files changed, 24 insertions(+) diff --git a/docs-master/Config.md b/docs-master/Config.md index 38887b3e2..dabf703e0 100644 --- a/docs-master/Config.md +++ b/docs-master/Config.md @@ -431,6 +431,9 @@ git: # If true, do not allow force pushes disableForcePushing: false + # If true, pass --no-verify to git push, skipping pre-push hooks + skipHookOnPush: false + # See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#predefined-commit-message-prefix commitPrefix: [] diff --git a/docs/Config.md b/docs/Config.md index 38887b3e2..f3b4764a2 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -383,6 +383,9 @@ git: # will be skipped when the commit message starts with 'WIP' skipHookPrefix: WIP + # If true, pass --no-verify when pushing, skipping pre-push hooks + skipHookOnPush: false + # If true, periodically fetch from remote autoFetch: true diff --git a/pkg/commands/git_commands/sync.go b/pkg/commands/git_commands/sync.go index d64a0910c..e6e7aee90 100644 --- a/pkg/commands/git_commands/sync.go +++ b/pkg/commands/git_commands/sync.go @@ -22,6 +22,7 @@ func NewSyncCommands(gitCommon *GitCommon) *SyncCommands { type PushOpts struct { Force bool ForceWithLease bool + NoVerify bool CurrentBranch string UpstreamRemote string UpstreamBranch string @@ -36,6 +37,7 @@ func (self *SyncCommands) PushCmdObj(task gocui.Task, opts PushOpts) (*oscommand cmdArgs := NewGitCmd("push"). ArgIf(opts.Force, "--force"). ArgIf(opts.ForceWithLease, "--force-with-lease"). + ArgIf(opts.NoVerify, "--no-verify"). ArgIf(opts.SetUpstream, "--set-upstream"). ArgIf(opts.UpstreamRemote != "", opts.UpstreamRemote). ArgIf(opts.UpstreamBranch != "", fmt.Sprintf("refs/heads/%s:%s", opts.CurrentBranch, opts.UpstreamBranch)). diff --git a/pkg/commands/git_commands/sync_test.go b/pkg/commands/git_commands/sync_test.go index fdc44a6b9..3fa680f17 100644 --- a/pkg/commands/git_commands/sync_test.go +++ b/pkg/commands/git_commands/sync_test.go @@ -81,6 +81,14 @@ func TestSyncPush(t *testing.T) { assert.NoError(t, err) }, }, + { + testName: "Push with no-verify", + opts: PushOpts{NoVerify: true}, + test: func(cmdObj *oscommands.CmdObj, err error) { + assert.Equal(t, cmdObj.Args(), []string{"git", "push", "--no-verify"}) + assert.NoError(t, err) + }, + }, { testName: "Push with remote branch but no origin", opts: PushOpts{ diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index abf591801..c6933341c 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -300,6 +300,8 @@ type GitConfig struct { OverrideGpg bool `yaml:"overrideGpg"` // If true, do not allow force pushes DisableForcePushing bool `yaml:"disableForcePushing"` + // If true, pass --no-verify to git push, skipping pre-push hooks + SkipHookOnPush bool `yaml:"skipHookOnPush"` // See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#predefined-commit-message-prefix CommitPrefix []CommitPrefixConfig `yaml:"commitPrefix"` // See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#predefined-commit-message-prefix diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 023ac0d25..9b0eb4a82 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -200,6 +200,7 @@ func (self *SyncController) pushAux(currentBranch *models.Branch, opts pushOpts) git_commands.PushOpts{ Force: opts.force, ForceWithLease: opts.forceWithLease, + NoVerify: self.c.UserConfig().Git.SkipHookOnPush, CurrentBranch: currentBranch.Name, UpstreamRemote: opts.upstreamRemote, UpstreamBranch: opts.upstreamBranch, diff --git a/schema-master/config.json b/schema-master/config.json index 0e880b066..006390990 100644 --- a/schema-master/config.json +++ b/schema-master/config.json @@ -393,6 +393,11 @@ "description": "If true, do not allow force pushes", "default": false }, + "skipHookOnPush": { + "type": "boolean", + "description": "If true, pass --no-verify to git push, skipping pre-push hooks", + "default": false + }, "commitPrefix": { "items": { "$ref": "#/$defs/CommitPrefixConfig"