@@ -174,13 +174,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
174174 return
175175 }
176176
177- if ! repo .AllowsPulls () {
178- // We can stop there's no need to go any further
179- ctx .JSON (http .StatusOK , private.HookPostReceiveResult {
180- RepoWasEmpty : wasEmpty ,
181- })
182- return
183- }
184177 baseRepo = repo
185178
186179 if repo .IsFork {
@@ -192,7 +185,17 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
192185 })
193186 return
194187 }
195- baseRepo = repo .BaseRepo
188+ if repo .BaseRepo .AllowsPulls () {
189+ baseRepo = repo .BaseRepo
190+ }
191+ }
192+
193+ if ! baseRepo .AllowsPulls () {
194+ // We can stop there's no need to go any further
195+ ctx .JSON (http .StatusOK , private.HookPostReceiveResult {
196+ RepoWasEmpty : wasEmpty ,
197+ })
198+ return
196199 }
197200 }
198201
@@ -218,14 +221,14 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
218221 branch = fmt .Sprintf ("%s:%s" , repo .OwnerName , branch )
219222 }
220223 results = append (results , private.HookPostReceiveBranchResult {
221- Message : setting .Git .PullRequestPushMessage && repo .AllowsPulls (),
224+ Message : setting .Git .PullRequestPushMessage && baseRepo .AllowsPulls (),
222225 Create : true ,
223226 Branch : branch ,
224227 URL : fmt .Sprintf ("%s/compare/%s...%s" , baseRepo .HTMLURL (), util .PathEscapeSegments (baseRepo .DefaultBranch ), util .PathEscapeSegments (branch )),
225228 })
226229 } else {
227230 results = append (results , private.HookPostReceiveBranchResult {
228- Message : setting .Git .PullRequestPushMessage && repo .AllowsPulls (),
231+ Message : setting .Git .PullRequestPushMessage && baseRepo .AllowsPulls (),
229232 Create : false ,
230233 Branch : branch ,
231234 URL : fmt .Sprintf ("%s/pulls/%d" , baseRepo .HTMLURL (), pr .Index ),
0 commit comments