Skip to content
Open
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
3 changes: 3 additions & 0 deletions docs-master/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand Down
3 changes: 3 additions & 0 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions pkg/commands/git_commands/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func NewSyncCommands(gitCommon *GitCommon) *SyncCommands {
type PushOpts struct {
Force bool
ForceWithLease bool
NoVerify bool
CurrentBranch string
UpstreamRemote string
UpstreamBranch string
Expand All @@ -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)).
Expand Down
8 changes: 8 additions & 0 deletions pkg/commands/git_commands/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/gui/controllers/sync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions schema-master/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down