MCPcopy Create free account
hub / github.com/gogs/gogs / checkKeyContent

Function checkKeyContent

internal/database/ssh_key.go:358–369  ·  view source on GitHub ↗

checkKeyContent onlys checks if key content has been used as public key, it is OK to use same key as deploy key for multiple repositories/users.

(content string)

Source from the content-addressed store, hash-verified

356// checkKeyContent onlys checks if key content has been used as public key,
357// it is OK to use same key as deploy key for multiple repositories/users.
358func checkKeyContent(content string) error {
359 has, err := x.Get(&PublicKey{
360 Content: content,
361 Type: KeyTypeUser,
362 })
363 if err != nil {
364 return err
365 } else if has {
366 return ErrKeyAlreadyExist{0, content}
367 }
368 return nil
369}
370
371func addKey(e Engine, key *PublicKey) (err error) {
372 // Calculate fingerprint.

Callers 2

AddPublicKeyFunction · 0.85
AddDeployKeyFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected