mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
feat(config): add skip push hooks
This commit is contained in:
parent
9046d5eb14
commit
edba327b7f
|
|
@ -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: []
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)).
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue