From d93e6232e829a1ade1f9540a701061967aa7d61d Mon Sep 17 00:00:00 2001
From: Lunny Xiao <xiaolunwen@gmail.com>
Date: Mon, 10 Jun 2019 19:35:13 +0800
Subject: Move PushUpdate dependency from models to repofiles (#6763)

* remove push_update

* move models.PushUpdate to repofiles.PushUpdate
---
 routers/private/hook.go | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'routers/private/hook.go')

diff --git a/routers/private/hook.go b/routers/private/hook.go
index 700c8bf332..a5985f161e 100644
--- a/routers/private/hook.go
+++ b/routers/private/hook.go
@@ -15,6 +15,7 @@ import (
 	"code.gitea.io/gitea/modules/git"
 	"code.gitea.io/gitea/modules/log"
 	"code.gitea.io/gitea/modules/private"
+	"code.gitea.io/gitea/modules/repofiles"
 	"code.gitea.io/gitea/modules/util"
 
 	macaron "gopkg.in/macaron.v1"
@@ -117,7 +118,15 @@ func HookPostReceive(ctx *macaron.Context) {
 	// or other less-standard refs spaces are ignored since there
 	// may be a very large number of them).
 	if strings.HasPrefix(refFullName, git.BranchPrefix) || strings.HasPrefix(refFullName, git.TagPrefix) {
-		if err := models.PushUpdate(branch, models.PushUpdateOptions{
+		repo, err := models.GetRepositoryByOwnerAndName(ownerName, repoName)
+		if err != nil {
+			log.Error("Failed to get repository: %s/%s Error: %v", ownerName, repoName, err)
+			ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
+				"err": fmt.Sprintf("Failed to get repository: %s/%s Error: %v", ownerName, repoName, err),
+			})
+			return
+		}
+		if err := repofiles.PushUpdate(repo, branch, models.PushUpdateOptions{
 			RefFullName:  refFullName,
 			OldCommitID:  oldCommitID,
 			NewCommitID:  newCommitID,
-- 
cgit v1.2.3