@@ -5,6 +5,7 @@ package agit
5
5
6
6
import (
7
7
"context"
8
+ "encoding/base64"
8
9
"fmt"
9
10
"os"
10
11
"strings"
@@ -18,17 +19,30 @@ import (
18
19
"code.gitea.io/gitea/modules/log"
19
20
"code.gitea.io/gitea/modules/private"
20
21
"code.gitea.io/gitea/modules/setting"
22
+ "code.gitea.io/gitea/modules/util"
21
23
notify_service "code.gitea.io/gitea/services/notify"
22
24
pull_service "code.gitea.io/gitea/services/pull"
23
25
)
24
26
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
+
25
35
// ProcReceive handle proc receive work
26
36
func ProcReceive (ctx context.Context , repo * repo_model.Repository , gitRepo * git.Repository , opts * private.HookOptions ) ([]private.HookProcReceiveRefResult , error ) {
27
37
results := make ([]private.HookProcReceiveRefResult , 0 , len (opts .OldCommitIDs ))
28
38
forcePush := opts .GitPushOptions .Bool (private .GitPushOptionForcePush )
29
39
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
+
32
46
objectFormat := git .ObjectFormatFromName (repo .ObjectFormatName )
33
47
userName := strings .ToLower (opts .UserName )
34
48
0 commit comments