@@ -5,6 +5,7 @@ package agit
55
66import  (
77	"context" 
8+ 	"encoding/base64" 
89	"fmt" 
910	"os" 
1011	"strings" 
@@ -18,17 +19,30 @@ import (
1819	"code.gitea.io/gitea/modules/log" 
1920	"code.gitea.io/gitea/modules/private" 
2021	"code.gitea.io/gitea/modules/setting" 
22+ 	"code.gitea.io/gitea/modules/util" 
2123	notify_service "code.gitea.io/gitea/services/notify" 
2224	pull_service "code.gitea.io/gitea/services/pull" 
2325)
2426
27+ func  parseAgitPushOptionValue (s  string ) string  {
28+ 	if  base64Value , ok  :=  strings .CutPrefix (s , "{base64}" ); ok  {
29+ 		decoded , err  :=  base64 .StdEncoding .DecodeString (base64Value )
30+ 		return  util .Iif (err  ==  nil , string (decoded ), s )
31+ 	}
32+ 	return  s 
33+ }
34+ 
2535// ProcReceive handle proc receive work 
2636func  ProcReceive (ctx  context.Context , repo  * repo_model.Repository , gitRepo  * git.Repository , opts  * private.HookOptions ) ([]private.HookProcReceiveRefResult , error ) {
2737	results  :=  make ([]private.HookProcReceiveRefResult , 0 , len (opts .OldCommitIDs ))
2838	forcePush  :=  opts .GitPushOptions .Bool (private .GitPushOptionForcePush )
2939	topicBranch  :=  opts .GitPushOptions ["topic" ]
30- 	title  :=  strings .TrimSpace (opts .GitPushOptions ["title" ])
31- 	description  :=  strings .TrimSpace (opts .GitPushOptions ["description" ])
40+ 
41+ 	// some options are base64-encoded with "{base64}" prefix if they contain new lines 
42+ 	// other agit push options like "issue", "reviewer" and "cc" are not supported 
43+ 	title  :=  parseAgitPushOptionValue (opts .GitPushOptions ["title" ])
44+ 	description  :=  parseAgitPushOptionValue (opts .GitPushOptions ["description" ])
45+ 
3246	objectFormat  :=  git .ObjectFormatFromName (repo .ObjectFormatName )
3347	userName  :=  strings .ToLower (opts .UserName )
3448
0 commit comments