mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 20:21:47 +01:00 
			
		
		
		
	* Clean-up HookPreReceive and restore functionality for pushing non-standard refs There was an inadvertent breaking change in #15629 meaning that notes refs and other git extension refs will be automatically rejected. Further following #14295 and #15629 the pre-recieve hook code is untenably long and too complex. This PR refactors the hook code and removes the incorrect forced rejection of non-standard refs. Fix #16688 Signed-off-by: Andrew Thornton <art27@cantab.net>
		
			
				
	
	
		
			35 lines
		
	
	
		
			986 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			986 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2021 The Gitea Authors. All rights reserved.
 | |
| // Use of this source code is governed by a MIT-style
 | |
| // license that can be found in the LICENSE file.
 | |
| 
 | |
| // Package private includes all internal routes. The package name internal is ideal but Golang is not allowed, so we use private as package name instead.
 | |
| package private
 | |
| 
 | |
| import (
 | |
| 	"net/http"
 | |
| 
 | |
| 	gitea_context "code.gitea.io/gitea/modules/context"
 | |
| 	"code.gitea.io/gitea/modules/git"
 | |
| 	"code.gitea.io/gitea/modules/private"
 | |
| 	"code.gitea.io/gitea/modules/web"
 | |
| 	"code.gitea.io/gitea/services/agit"
 | |
| )
 | |
| 
 | |
| // HookProcReceive proc-receive hook - only handles agit Proc-Receive requests at present
 | |
| func HookProcReceive(ctx *gitea_context.PrivateContext) {
 | |
| 	opts := web.GetForm(ctx).(*private.HookOptions)
 | |
| 	if !git.SupportProcReceive {
 | |
| 		ctx.Status(http.StatusNotFound)
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	results := agit.ProcRecive(ctx, opts)
 | |
| 	if ctx.Written() {
 | |
| 		return
 | |
| 	}
 | |
| 
 | |
| 	ctx.JSON(http.StatusOK, private.HookProcReceiveResult{
 | |
| 		Results: results,
 | |
| 	})
 | |
| }
 |