diff options
author | Ethan Koenig <etk39@cornell.edu> | 2017-02-05 09:35:03 -0500 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-02-05 22:35:03 +0800 |
commit | 027591a3a556477a26d6c849e1ed9b9a53c15110 (patch) | |
tree | a2530f9419e864fbb68e6b38dd7b28ce58f592b6 /routers/api/v1 | |
parent | e86d9351754f85b1508092b793dbd8a5cd1456f2 (diff) | |
download | gitea-027591a3a556477a26d6c849e1ed9b9a53c15110.tar.gz gitea-027591a3a556477a26d6c849e1ed9b9a53c15110.zip |
Redirects for renamed repos (#807)
* Redirects for renamed repos
* Remove unused phrase from locales
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/api.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index afdb2c0045..f89d6e3445 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -52,7 +52,14 @@ func repoAssignment() macaron.Handler { repo, err := models.GetRepositoryByName(owner.ID, repoName) if err != nil { if models.IsErrRepoNotExist(err) { - ctx.Status(404) + redirectRepoID, err := models.LookupRepoRedirect(owner.ID, repoName) + if err == nil { + context.RedirectToRepo(ctx.Context, redirectRepoID) + } else if models.IsErrRepoRedirectNotExist(err) { + ctx.Status(404) + } else { + ctx.Error(500, "LookupRepoRedirect", err) + } } else { ctx.Error(500, "GetRepositoryByName", err) } |