From 4b3400bd9c77347664cc3b968626991ac9fd5f6d Mon Sep 17 00:00:00 2001 From: Giteabot Date: Tue, 25 Mar 2025 15:56:44 +0800 Subject: [PATCH] Git client will follow 301 but 307 (#34005) (#34010) Backport #34005 by lunny Fix #28460 Co-authored-by: Lunny Xiao Co-authored-by: wxiaoguang --- services/context/repo.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/context/repo.go b/services/context/repo.go index 879b3fcb86..da6731df5a 100644 --- a/services/context/repo.go +++ b/services/context/repo.go @@ -356,7 +356,9 @@ func RedirectToRepo(ctx *Base, redirectRepoID int64) { if ctx.Req.URL.RawQuery != "" { redirectPath += "?" + ctx.Req.URL.RawQuery } - ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusTemporaryRedirect) + // Git client needs a 301 redirect by default to follow the new location + // It's not documentated in git documentation, but it's the behavior of git client + ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusMovedPermanently) } func repoAssignment(ctx *Context, repo *repo_model.Repository) {