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

Function checkDeployKey

internal/database/ssh_key.go:608–625  ·  view source on GitHub ↗
(e Engine, keyID, repoID int64, name string)

Source from the content-addressed store, hash-verified

606}
607
608func checkDeployKey(e Engine, keyID, repoID int64, name string) error {
609 // Note: We want error detail, not just true or false here.
610 has, err := e.Where("key_id = ? AND repo_id = ?", keyID, repoID).Get(new(DeployKey))
611 if err != nil {
612 return err
613 } else if has {
614 return ErrDeployKeyAlreadyExist{keyID, repoID}
615 }
616
617 has, err = e.Where("repo_id = ? AND name = ?", repoID, name).Get(new(DeployKey))
618 if err != nil {
619 return err
620 } else if has {
621 return ErrDeployKeyNameAlreadyUsed{repoID, name}
622 }
623
624 return nil
625}
626
627// addDeployKey adds new key-repo relation.
628func addDeployKey(e *xorm.Session, keyID, repoID int64, name, fingerprint string) (*DeployKey, error) {

Callers 1

addDeployKeyFunction · 0.70

Calls 2

WhereMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected