@ -13,6 +13,7 @@ import ( 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						"code.gitea.io/gitea/modules/context"   
					 
					 
					 
						"code.gitea.io/gitea/modules/context"   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						"code.gitea.io/gitea/modules/convert"   
					 
					 
					 
						"code.gitea.io/gitea/modules/convert"   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						"code.gitea.io/gitea/modules/git"   
					 
					 
					 
						"code.gitea.io/gitea/modules/git"   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						"code.gitea.io/gitea/modules/setting"   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						api  "code.gitea.io/gitea/modules/structs"   
					 
					 
					 
						api  "code.gitea.io/gitea/modules/structs"   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						"code.gitea.io/gitea/modules/web"   
					 
					 
					 
						"code.gitea.io/gitea/modules/web"   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						"code.gitea.io/gitea/routers/api/v1/utils"   
					 
					 
					 
						"code.gitea.io/gitea/routers/api/v1/utils"   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -140,7 +141,7 @@ func TestHook(ctx *context.APIContext) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						//   required: true
   
					 
					 
					 
						//   required: true
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						// - name: ref
   
					 
					 
					 
						// - name: ref
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						//   in: query
   
					 
					 
					 
						//   in: query
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						//   description: "The name of the commit/branch/tag. Default the repository’s default branch (usually master) "
   
					 
					 
					 
						//   description: "The name of the commit/branch/tag, indicates which commit will be loaded to the webhook payload. "
   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
						//   type: string
   
					 
					 
					 
						//   type: string
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						//   required: false
   
					 
					 
					 
						//   required: false
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						// responses:
   
					 
					 
					 
						// responses:
   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -153,6 +154,11 @@ func TestHook(ctx *context.APIContext) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							return   
					 
					 
					 
							return   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						}   
					 
					 
					 
						}   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						ref  :=  git . BranchPrefix  +  ctx . Repo . Repository . DefaultBranch   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						if  r  :=  ctx . FormTrim ( "ref" ) ;  r  !=  ""  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							ref  =  r   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						}   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						hookID  :=  ctx . ParamsInt64 ( ":id" )   
					 
					 
					 
						hookID  :=  ctx . ParamsInt64 ( ":id" )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						hook ,  err  :=  utils . GetRepoHook ( ctx ,  ctx . Repo . Repository . ID ,  hookID )   
					 
					 
					 
						hook ,  err  :=  utils . GetRepoHook ( ctx ,  ctx . Repo . Repository . ID ,  hookID )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						if  err  !=  nil  {   
					 
					 
					 
						if  err  !=  nil  {   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -161,10 +167,12 @@ func TestHook(ctx *context.APIContext) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						commit  :=  convert . ToPayloadCommit ( ctx . Repo . Repository ,  ctx . Repo . Commit )   
					 
					 
					 
						commit  :=  convert . ToPayloadCommit ( ctx . Repo . Repository ,  ctx . Repo . Commit )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						commitID  :=  ctx . Repo . Commit . ID . String ( )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						if  err  :=  webhook_service . PrepareWebhook ( hook ,  ctx . Repo . Repository ,  webhook . HookEventPush ,  & api . PushPayload {   
					 
					 
					 
						if  err  :=  webhook_service . PrepareWebhook ( hook ,  ctx . Repo . Repository ,  webhook . HookEventPush ,  & api . PushPayload {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							Ref :         git . BranchPrefix  +  ctx . Repo . Repository . DefaultBranch ,   
					 
					 
					 
							Ref :         ref ,   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
							Before :      ctx . Repo . Commit . ID . String ( ) ,   
					 
					 
					 
							Before :      commitID ,   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
							After :       ctx . Repo . Commit . ID . String ( ) ,   
					 
					 
					 
							After :       commitID ,   
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							CompareURL :  setting . AppURL  +  ctx . Repo . Repository . ComposeCompareURL ( commitID ,  commitID ) ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							Commits :     [ ] * api . PayloadCommit { commit } ,   
					 
					 
					 
							Commits :     [ ] * api . PayloadCommit { commit } ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							HeadCommit :  commit ,   
					 
					 
					 
							HeadCommit :  commit ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							Repo :        convert . ToRepo ( ctx . Repo . Repository ,  perm . AccessModeNone ) ,   
					 
					 
					 
							Repo :        convert . ToRepo ( ctx . Repo . Repository ,  perm . AccessModeNone ) ,