From ec512349c4089675e1df43e1c62d01f238c5c74d Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Mon, 10 Oct 2022 14:19:20 +0000 Subject: [PATCH 1/2] Redirect to new repository owner. --- modules/context/repo.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/context/repo.go b/modules/context/repo.go index 1742683d3cf1d..ebaaa9d974101 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -451,11 +451,17 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { owner, err = user_model.GetUserByName(ctx, userName) if err != nil { if user_model.IsErrUserNotExist(err) { - if ctx.FormString("go-get") == "1" { - EarlyResponseForGoGetMeta(ctx) - return + if redirectUserID, err := user_model.LookupUserRedirect(userName); err == nil { + RedirectToUser(ctx, userName, redirectUserID) + } else if user_model.IsErrUserRedirectNotExist(err) { + if ctx.FormString("go-get") == "1" { + EarlyResponseForGoGetMeta(ctx) + return + } + ctx.NotFound("GetUserByName", nil) + } else { + ctx.ServerError("LookupUserRedirect", err) } - ctx.NotFound("GetUserByName", nil) } else { ctx.ServerError("GetUserByName", err) } From f933331303849d0b1a15f315534706e467195b42 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Mon, 10 Oct 2022 18:01:03 +0000 Subject: [PATCH 2/2] Early response for go-get. --- modules/context/repo.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/context/repo.go b/modules/context/repo.go index ebaaa9d974101..1a0263a3307a1 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -451,13 +451,16 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { owner, err = user_model.GetUserByName(ctx, userName) if err != nil { if user_model.IsErrUserNotExist(err) { + // go-get does not support redirects + // https://github.com/golang/go/issues/19760 + if ctx.FormString("go-get") == "1" { + EarlyResponseForGoGetMeta(ctx) + return + } + if redirectUserID, err := user_model.LookupUserRedirect(userName); err == nil { RedirectToUser(ctx, userName, redirectUserID) } else if user_model.IsErrUserRedirectNotExist(err) { - if ctx.FormString("go-get") == "1" { - EarlyResponseForGoGetMeta(ctx) - return - } ctx.NotFound("GetUserByName", nil) } else { ctx.ServerError("LookupUserRedirect", err)