Skip to content

Commit

Permalink
Show repo trust prompt only if interactive ⚓
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyx committed Mar 17, 2021
1 parent 55076eb commit fb904fc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions githooks/apps/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ func setMainVariables(repoPath string) (HookSettings, UISettings) {
promptCtx, err := prompt.CreateContext(log, true, false)
log.DebugIfF(err != nil, "Prompt setup failed -> using fallback.")

isTrusted, hasTrustFile := hooks.IsRepoTrusted(gitx, repoPath)
if !isTrusted && hasTrustFile {
isTrusted = showTrustRepoPrompt(gitx, promptCtx)
}

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

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

s := HookSettings{
Args: os.Args[2:],
ExecX: execx,
Expand Down Expand Up @@ -239,7 +239,7 @@ func showTrustRepoPrompt(gitx *git.Context, promptCtx prompt.IContext) (isTruste
return
}

if answer == "y" || answer == "Y" {
if answer == "y" {
err := hooks.SetTrustAllSetting(gitx, true, false)
log.AssertNoErrorF(err, "Could not store trust setting.")
isTrusted = true
Expand Down

0 comments on commit fb904fc

Please sign in to comment.