Skip to content

Commit 356b707

Browse files
lunnywxiaoguang
andauthored
Git client will follow 301 but 307 (#34005)
Fix #28460 --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent 41c946a commit 356b707

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
@@ -328,7 +328,9 @@ func RedirectToRepo(ctx *Base, redirectRepoID int64) {
328328
if ctx.Req.URL.RawQuery != "" {
329329
redirectPath += "?" + ctx.Req.URL.RawQuery
330330
}
331-
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusTemporaryRedirect)
331+
// Git client needs a 301 redirect by default to follow the new location
332+
// It's not documentated in git documentation, but it's the behavior of git client
333+
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusMovedPermanently)
332334
}
333335

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

0 commit comments

Comments
 (0)