summaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-08 01:04:12 +0800
committerUnknwon <u@gogs.io>2015-08-08 01:04:12 +0800
commit3d0583df0f1704bc0e1c0d1348f2054515680fed (patch)
treed8a91c0075a73ce0249179c5ef02092dbc139a5c /routers/repo
parent45adb9b7a38cca896bf8fb3f27ccb29fc244b395 (diff)
downloadgitea-3d0583df0f1704bc0e1c0d1348f2054515680fed.tar.gz
gitea-3d0583df0f1704bc0e1c0d1348f2054515680fed.zip
fix private repo cannot trigger hook by SSH
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/setting.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 8f6ef1787b..05881a67ef 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -586,7 +586,26 @@ func getOrgRepoCtx(ctx *middleware.Context) (*OrgRepoCtx, error) {
}
func TriggerHook(ctx *middleware.Context) {
- models.HookQueue.AddRepoID(ctx.Repo.Repository.Id)
+ u, err := models.GetUserByName(ctx.Params(":username"))
+ if err != nil {
+ if models.IsErrUserNotExist(err) {
+ ctx.Handle(404, "GetUserByName", err)
+ } else {
+ ctx.Handle(500, "GetUserByName", err)
+ }
+ return
+ }
+
+ repo, err := models.GetRepositoryByName(u.Id, ctx.Params(":reponame"))
+ if err != nil {
+ if models.IsErrRepoNotExist(err) {
+ ctx.Handle(404, "GetRepositoryByName", err)
+ } else {
+ ctx.Handle(500, "GetRepositoryByName", err)
+ }
+ return
+ }
+ models.HookQueue.AddRepoID(repo.Id)
}
func GitHooks(ctx *middleware.Context) {