summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/repo.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index 848a76fe88..4d7320a789 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1564,6 +1564,11 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
}
}
+ // If there was previously a redirect at this location, remove it.
+ if err = deleteRepoRedirect(sess, newOwner.ID, repo.Name); err != nil {
+ return fmt.Errorf("delete repo redirect: %v", err)
+ }
+
return sess.Commit()
}
@@ -1614,7 +1619,18 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)
RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath())
}
- return nil
+ sess := x.NewSession()
+ defer sess.Close()
+ if err = sess.Begin(); err != nil {
+ return fmt.Errorf("sess.Begin: %v", err)
+ }
+
+ // If there was previously a redirect at this location, remove it.
+ if err = deleteRepoRedirect(sess, u.ID, newRepoName); err != nil {
+ return fmt.Errorf("delete repo redirect: %v", err)
+ }
+
+ return sess.Commit()
}
func getRepositoriesByForkID(e Engine, forkID int64) ([]*Repository, error) {