mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 03:48:30 +02:00
Backport #35037 by wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
6dc19fc29a
commit
ec0c418719
@ -4,9 +4,11 @@ This changelog goes through the changes that have been made in each release
|
|||||||
without substantial changes to our git log; to see the highlights of what has
|
without substantial changes to our git log; to see the highlights of what has
|
||||||
been added to each release, please refer to the [blog](https://blog.gitea.com).
|
been added to each release, please refer to the [blog](https://blog.gitea.com).
|
||||||
|
|
||||||
## [1.24.3](https://github.com/go-gitea/gitea/releases/tag/1.24.3) - 2025-07-10
|
## [1.24.3](https://github.com/go-gitea/gitea/releases/tag/1.24.3) - 2025-07-11
|
||||||
|
|
||||||
* BUGFIXES
|
* BUGFIXES
|
||||||
|
* Support base64-encoded agit push options (#35037) (#35041)
|
||||||
|
* Make submodule link work with relative path (#35034) (#35038)
|
||||||
* Fix bug when displaying git user avatar in commits list (#35006)
|
* Fix bug when displaying git user avatar in commits list (#35006)
|
||||||
* Fix API response for swagger spec (#35029)
|
* Fix API response for swagger spec (#35029)
|
||||||
* Start automerge check again after the conflict check and the schedule (#34988) (#35002)
|
* Start automerge check again after the conflict check and the schedule (#34988) (#35002)
|
||||||
|
@ -5,6 +5,7 @@ package agit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -18,17 +19,30 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/private"
|
"code.gitea.io/gitea/modules/private"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/util"
|
||||||
notify_service "code.gitea.io/gitea/services/notify"
|
notify_service "code.gitea.io/gitea/services/notify"
|
||||||
pull_service "code.gitea.io/gitea/services/pull"
|
pull_service "code.gitea.io/gitea/services/pull"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func parseAgitPushOptionValue(s string) string {
|
||||||
|
if base64Value, ok := strings.CutPrefix(s, "{base64}"); ok {
|
||||||
|
decoded, err := base64.StdEncoding.DecodeString(base64Value)
|
||||||
|
return util.Iif(err == nil, string(decoded), s)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
// ProcReceive handle proc receive work
|
// ProcReceive handle proc receive work
|
||||||
func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, opts *private.HookOptions) ([]private.HookProcReceiveRefResult, error) {
|
func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, opts *private.HookOptions) ([]private.HookProcReceiveRefResult, error) {
|
||||||
results := make([]private.HookProcReceiveRefResult, 0, len(opts.OldCommitIDs))
|
results := make([]private.HookProcReceiveRefResult, 0, len(opts.OldCommitIDs))
|
||||||
forcePush := opts.GitPushOptions.Bool(private.GitPushOptionForcePush)
|
forcePush := opts.GitPushOptions.Bool(private.GitPushOptionForcePush)
|
||||||
topicBranch := opts.GitPushOptions["topic"]
|
topicBranch := opts.GitPushOptions["topic"]
|
||||||
title := strings.TrimSpace(opts.GitPushOptions["title"])
|
|
||||||
description := strings.TrimSpace(opts.GitPushOptions["description"])
|
// some options are base64-encoded with "{base64}" prefix if they contain new lines
|
||||||
|
// other agit push options like "issue", "reviewer" and "cc" are not supported
|
||||||
|
title := parseAgitPushOptionValue(opts.GitPushOptions["title"])
|
||||||
|
description := parseAgitPushOptionValue(opts.GitPushOptions["description"])
|
||||||
|
|
||||||
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
|
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
|
||||||
userName := strings.ToLower(opts.UserName)
|
userName := strings.ToLower(opts.UserName)
|
||||||
|
|
||||||
|
16
services/agit/agit_test.go
Normal file
16
services/agit/agit_test.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package agit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestParseAgitPushOptionValue(t *testing.T) {
|
||||||
|
assert.Equal(t, "a", parseAgitPushOptionValue("a"))
|
||||||
|
assert.Equal(t, "a", parseAgitPushOptionValue("{base64}YQ=="))
|
||||||
|
assert.Equal(t, "{base64}invalid value", parseAgitPushOptionValue("{base64}invalid value"))
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user