Skip to content

Commit

Permalink
fix: Show no prompt when disabled ⚓ (#89)
Browse files Browse the repository at this point in the history
Co-authored-by: Nützi, Gabriel <[email protected]>
  • Loading branch information
gabyx and Nützi, Gabriel authored Mar 21, 2022
1 parent 06b29e4 commit 6b37a2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions githooks/apps/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ func mainRun() (exitCode int) {

defer storePendingData(&settings, &uiSettings, &ignores, &checksums)

if hooks.IsGithooksDisabled(settings.GitX, true) {
if settings.Disabled {
// Githooks is disabled, run minimal stuff.
executeLFSHooks(&settings)
executeOldHook(&settings, &uiSettings, &ignores, &checksums)

Expand Down Expand Up @@ -160,12 +161,13 @@ func setupSettings(repoPath string) (HookSettings, UISettings) {
promptx, err := prompt.CreateContext(log, true, false)
log.DebugIfF(err != nil, "Prompt setup failed -> using fallback.")

isGithooksDisabled := hooks.IsGithooksDisabled(gitx, true)
nonInteractive := hooks.IsRunnerNonInteractive(gitx, git.Traverse)
skipNonExistingSharedHooks := hooks.SkipNonExistingSharedHooks(gitx, git.Traverse)
skipUntrustedHooks, _ := hooks.SkipUntrustedHooks(gitx, git.Traverse)

isTrusted, hasTrustFile, trustAllSet := hooks.IsRepoTrusted(gitx, repoPath)
if !isTrusted && hasTrustFile && !trustAllSet && !nonInteractive {
if !isTrusted && hasTrustFile && !trustAllSet && !nonInteractive && !isGithooksDisabled {
isTrusted = showTrustRepoPrompt(gitx, promptx)
}

Expand All @@ -186,7 +188,8 @@ func setupSettings(repoPath string) (HookSettings, UISettings) {

SkipNonExistingSharedHooks: skipNonExistingSharedHooks,
SkipUntrustedHooks: skipUntrustedHooks,
NonInteractive: nonInteractive}
NonInteractive: nonInteractive,
Disabled: isGithooksDisabled}

logInvocation(&s)

Expand Down
1 change: 1 addition & 0 deletions githooks/apps/runner/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type HookSettings struct {
SkipNonExistingSharedHooks bool // If Githooks should skip non-existing shared hooks.
SkipUntrustedHooks bool // If Githooks should skip active untrusted hooks.
NonInteractive bool // If all non-fatal prompts should be default answered.
Disabled bool // If Githooks has been disabled.
}

func (s HookSettings) toString() string {
Expand Down

0 comments on commit 6b37a2d

Please sign in to comment.