Skip to content

Commit 4b3400b

Browse files
GiteaBotlunnywxiaoguang
authored
Git client will follow 301 but 307 (#34005) (#34010)
Backport #34005 by lunny Fix #28460 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent 7758df4 commit 4b3400b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

services/context/repo.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ func RedirectToRepo(ctx *Base, redirectRepoID int64) {
356356
if ctx.Req.URL.RawQuery != "" {
357357
redirectPath += "?" + ctx.Req.URL.RawQuery
358358
}
359-
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusTemporaryRedirect)
359+
// Git client needs a 301 redirect by default to follow the new location
360+
// It's not documentated in git documentation, but it's the behavior of git client
361+
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusMovedPermanently)
360362
}
361363

362364
func repoAssignment(ctx *Context, repo *repo_model.Repository) {

0 commit comments

Comments
 (0)