summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index 5e96a4e931..873fd407fb 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1756,6 +1756,17 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
return ErrRepoNotExist{repoID, uid, "", ""}
}
+ // Delete Deploy Keys
+ deployKeys, err := listDeployKeys(sess, repo.ID)
+ if err != nil {
+ return fmt.Errorf("listDeployKeys: %v", err)
+ }
+ for _, dKey := range deployKeys {
+ if err := deleteDeployKey(sess, doer, dKey.ID); err != nil {
+ return fmt.Errorf("deleteDeployKeys: %v", err)
+ }
+ }
+
if cnt, err := sess.ID(repoID).Delete(&Repository{}); err != nil {
return err
} else if cnt != 1 {
@@ -1898,6 +1909,12 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
}
if err = sess.Commit(); err != nil {
+ if len(deployKeys) > 0 {
+ // We need to rewrite the public keys because the commit failed
+ if err2 := RewriteAllPublicKeys(); err2 != nil {
+ return fmt.Errorf("Commit: %v SSH Keys: %v", err, err2)
+ }
+ }
return fmt.Errorf("Commit: %v", err)
}