summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/pull.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-22 23:21:55 +0800
committerGitHub <noreply@github.com>2021-11-22 23:21:55 +0800
commitbaed01f24753afb600a2984dcb9bcda0bb8502b6 (patch)
tree5621ef980b6b0067a21c86be7e4808d83c0538ab /routers/web/repo/pull.go
parentc2ab19888f92fbdec4276a16d224e8de80d1d1dd (diff)
downloadgitea-baed01f24753afb600a2984dcb9bcda0bb8502b6.tar.gz
gitea-baed01f24753afb600a2984dcb9bcda0bb8502b6.zip
Remove unnecessary attributes of User struct (#17745)
* Remove unnecessary functions of User struct * Move more database methods out of user struct * Move more database methods out of user struct * Fix template failure * Fix bug * Remove finished FIXME * remove unnecessary code
Diffstat (limited to 'routers/web/repo/pull.go')
-rw-r--r--routers/web/repo/pull.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index a7afc3a05c..83e353833f 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -108,23 +108,23 @@ func getForkRepository(ctx *context.Context) *models.Repository {
ctx.Data["repo_name"] = forkRepo.Name
ctx.Data["description"] = forkRepo.Description
ctx.Data["IsPrivate"] = forkRepo.IsPrivate || forkRepo.Owner.Visibility == structs.VisibleTypePrivate
- canForkToUser := forkRepo.OwnerID != ctx.User.ID && !ctx.User.HasForkedRepo(forkRepo.ID)
+ canForkToUser := forkRepo.OwnerID != ctx.User.ID && !models.HasForkedRepo(ctx.User.ID, forkRepo.ID)
ctx.Data["ForkRepo"] = forkRepo
- if err := ctx.User.GetOwnedOrganizations(); err != nil {
- ctx.ServerError("GetOwnedOrganizations", err)
+ ownedOrgs, err := models.GetOwnedOrgsByUserID(ctx.User.ID)
+ if err != nil {
+ ctx.ServerError("GetOwnedOrgsByUserID", err)
return nil
}
- var orgs []*models.User
- for _, org := range ctx.User.OwnedOrgs {
- if forkRepo.OwnerID != org.ID && !org.HasForkedRepo(forkRepo.ID) {
+ var orgs []*models.Organization
+ for _, org := range ownedOrgs {
+ if forkRepo.OwnerID != org.ID && !models.HasForkedRepo(org.ID, forkRepo.ID) {
orgs = append(orgs, org)
}
}
var traverseParentRepo = forkRepo
- var err error
for {
if ctx.User.ID == traverseParentRepo.OwnerID {
canForkToUser = false
@@ -200,8 +200,8 @@ func ForkPost(ctx *context.Context) {
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), tplFork, &form)
return
}
- repo, has := models.HasForkedRepo(ctxUser.ID, traverseParentRepo.ID)
- if has {
+ repo := models.GetForkedRepo(ctxUser.ID, traverseParentRepo.ID)
+ if repo != nil {
ctx.Redirect(ctxUser.HomeLink() + "/" + url.PathEscape(repo.Name))
return
}