Skip to content

Commit

Permalink
Do not show prompt on already set 'githooks.trustAll' (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyx authored Dec 6, 2021
1 parent 77ffabe commit 16a440b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions githooks/apps/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func setupSettings(repoPath string) (HookSettings, UISettings) {
skipNonExistingSharedHooks, _ := hooks.SkipNonExistingSharedHooks(gitx, git.Traverse)
skipUntrustedHooks, _ := hooks.SkipUntrustedHooks(gitx, git.Traverse)

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

Expand Down
2 changes: 1 addition & 1 deletion githooks/cmd/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func PrepareListHookState(
shared[hooks.SharedHookTypeV.Global], err = hooks.LoadConfigSharedHooks(ctx.InstallDir, ctx.GitX, git.GlobalScope)
ctx.Log.AssertNoErrorF(err, "Could not load global shared hooks.")

isTrusted, _ := hooks.IsRepoTrusted(ctx.GitX, repoDir)
isTrusted, _, _ := hooks.IsRepoTrusted(ctx.GitX, repoDir)
isDisabled := hooks.IsGithooksDisabled(ctx.GitX, true)

state = &ListingState{
Expand Down
4 changes: 2 additions & 2 deletions githooks/hooks/trusted.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ func SetTrustAllSetting(gitx *git.Context, enable bool, reset bool) error {
// On any error `false` is reported together with the error.
func IsRepoTrusted(
gitx *git.Context,
repoPath string) (isTrusted bool, hasTrustFile bool) {
repoPath string) (isTrusted bool, hasTrustFile bool, trustAllSet bool) {

trustFile := GetTrustMarkerFile(repoPath)

if cm.IsFile(trustFile) {
hasTrustFile = true
isTrusted, _ = GetTrustAllSetting(gitx)
isTrusted, trustAllSet = GetTrustAllSetting(gitx)
}

return
Expand Down

0 comments on commit 16a440b

Please sign in to comment.