summaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2017-09-05 15:45:18 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-09-05 21:45:18 +0800
commit7c417bbb0d8f3213f34db50f62013e20492d044f (patch)
tree45898dac8949fdd6c8c948f7d2a737e1871c7331 /models/error.go
parent5f4210a9b0c8c42fb8f157c233ddc5aec6d9972d (diff)
downloadgitea-7c417bbb0d8f3213f34db50f62013e20492d044f.tar.gz
gitea-7c417bbb0d8f3213f34db50f62013e20492d044f.zip
Only check at least one email gpg key (#2266)
* Only require one email (possibly not yet validated) * Update message error and check validation of commit * Add integrations tests * Complete integration for import * Add pre-check/optimization * Add some test (not finished) * Finish * Fix fixtures * Fix typo * Don't guess key ID
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/models/error.go b/models/error.go
index 74551ad8f7..2adb4b45e1 100644
--- a/models/error.go
+++ b/models/error.go
@@ -4,9 +4,7 @@
package models
-import (
- "fmt"
-)
+import "fmt"
// ErrNameReserved represents a "reserved name" error.
type ErrNameReserved struct {
@@ -260,19 +258,19 @@ func (err ErrKeyNameAlreadyUsed) Error() string {
return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
}
-// ErrGPGEmailNotFound represents a "ErrGPGEmailNotFound" kind of error.
-type ErrGPGEmailNotFound struct {
- Email string
+// ErrGPGNoEmailFound represents a "ErrGPGNoEmailFound" kind of error.
+type ErrGPGNoEmailFound struct {
+ FailedEmails []string
}
-// IsErrGPGEmailNotFound checks if an error is a ErrGPGEmailNotFound.
-func IsErrGPGEmailNotFound(err error) bool {
- _, ok := err.(ErrGPGEmailNotFound)
+// IsErrGPGNoEmailFound checks if an error is a ErrGPGNoEmailFound.
+func IsErrGPGNoEmailFound(err error) bool {
+ _, ok := err.(ErrGPGNoEmailFound)
return ok
}
-func (err ErrGPGEmailNotFound) Error() string {
- return fmt.Sprintf("failed to found email or is not confirmed : %s", err.Email)
+func (err ErrGPGNoEmailFound) Error() string {
+ return fmt.Sprintf("none of the emails attached to the GPG key could be found: %v", err.FailedEmails)
}
// ErrGPGKeyParsing represents a "ErrGPGKeyParsing" kind of error.