diff --git a/docs-master/Config.md b/docs-master/Config.md index 857a4e359..57a054fb3 100644 --- a/docs-master/Config.md +++ b/docs-master/Config.md @@ -483,6 +483,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 857a4e359..ef5fef16e 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -429,6 +429,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 0400b4e26..1c1a96d2c 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 6a7702586..b86a214a6 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 9738186d9..85a18732a 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -337,6 +337,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 61b92747b..83a5039e9 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 45a2b9efe..1ff1112ca 100644 --- a/schema-master/config.json +++ b/schema-master/config.json @@ -469,6 +469,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"