Handle redirects in git clone commands (#6688)

Add support for repo_redirect objects in the git smart http
handler so that when a user clones a repo that has been moved
or renamed, they are redirected to the new location.

This requires that the query string be included in the redirect
as well, so that is added.

Signed-off-by: James E. Blair <jeblair@redhat.com>
This commit is contained in:
James E. Blair authored and Lauris BH committed 2019-04-25 08:51:40 +03:00
1 parent 0064535ad2
commit dabee9b1a4
2 files changed
+20 -2

No files matched your search

+3
View File
@@ -223,6 +223,9 @@ func RedirectToRepo(ctx *Context, redirectRepoID int64) {
fmt.Sprintf("%s/%s", repo.MustOwnerName(), repo.Name),
1,
)
if ctx.Req.URL.RawQuery != "" {
redirectPath += "?" + ctx.Req.URL.RawQuery
}
ctx.Redirect(redirectPath)
}