From 7e965a2939ce6b19495224e0b607aaf09baa30ef Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Sat, 3 Mar 2018 13:31:41 +0100 Subject: [PATCH 1/3] Don't write to log NoCommitterAccount It's way too verbose, and the information is also printed to the user already. Fixes #3602. --- models/gpg_key.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/gpg_key.go b/models/gpg_key.go index b7d86c8bfe9fd..a95e451aaf512 100644 --- a/models/gpg_key.go +++ b/models/gpg_key.go @@ -374,7 +374,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification { //Find Committer account committer, err := GetUserByEmail(c.Committer.Email) //This find the user by primary email or activated email so commit will not be valid if email is not if err != nil { //Skipping not user for commiter - log.Error(3, "NoCommitterAccount: %v", err) + // No user that we know of has that PGP key. return &CommitVerification{ Verified: false, Reason: "gpg.error.no_committer_account", From f42e2d4771b8d158a7dbb8ec5ab34ffa4e7e1893 Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Sat, 3 Mar 2018 16:17:23 +0100 Subject: [PATCH 2/3] ignore err only if it's a ErrUserNotExist --- models/gpg_key.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/gpg_key.go b/models/gpg_key.go index a95e451aaf512..ca41c7fc7270f 100644 --- a/models/gpg_key.go +++ b/models/gpg_key.go @@ -374,7 +374,11 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification { //Find Committer account committer, err := GetUserByEmail(c.Committer.Email) //This find the user by primary email or activated email so commit will not be valid if email is not if err != nil { //Skipping not user for commiter - // No user that we know of has that PGP key. + // We can expect this to often be an ErrUserNotExist. in the case + // it is not, however, it is important to log it. + if _, ok := err.(ErrUserNotExist); !ok { + log.Error(3, "GetUserByEmail: %v", err) + } return &CommitVerification{ Verified: false, Reason: "gpg.error.no_committer_account", From 93f37a1fa774600bb3875842c5eb7d18fc976abe Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Sat, 3 Mar 2018 16:18:41 +0100 Subject: [PATCH 3/3] Replace with IsErrUserNotExist --- models/gpg_key.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/gpg_key.go b/models/gpg_key.go index ca41c7fc7270f..45da889504ac6 100644 --- a/models/gpg_key.go +++ b/models/gpg_key.go @@ -376,7 +376,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification { if err != nil { //Skipping not user for commiter // We can expect this to often be an ErrUserNotExist. in the case // it is not, however, it is important to log it. - if _, ok := err.(ErrUserNotExist); !ok { + if !IsErrUserNotExist(err) { log.Error(3, "GetUserByEmail: %v", err) } return &CommitVerification{