Skip to content

Commit 0a6dcb0

Browse files
committed
Merge branch 'release/v1.23' into lunny/release_note_1.23.7
2 parents c43c44d + 9ef2a33 commit 0a6dcb0

File tree

6 files changed

+135
-5
lines changed

6 files changed

+135
-5
lines changed

docker/root/etc/s6/openssh/setup

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ if [ -e /data/ssh/ssh_host_ecdsa_cert ]; then
3131
SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa_cert"}
3232
fi
3333

34+
if [ -e /data/ssh/ssh_host_ed25519-cert.pub ]; then
35+
SSH_ED25519_CERT=${SSH_ED25519_CERT:-"/data/ssh/ssh_host_ed25519-cert.pub"}
36+
fi
37+
38+
if [ -e /data/ssh/ssh_host_rsa-cert.pub ]; then
39+
SSH_RSA_CERT=${SSH_RSA_CERT:-"/data/ssh/ssh_host_rsa-cert.pub"}
40+
fi
41+
42+
if [ -e /data/ssh/ssh_host_ecdsa-cert.pub ]; then
43+
SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa-cert.pub"}
44+
fi
45+
3446
if [ -d /etc/ssh ]; then
3547
SSH_PORT=${SSH_PORT:-"22"} \
3648
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \

modules/actions/workflows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ func matchPullRequestEvent(gitRepo *git.Repository, commit *git.Commit, prPayloa
463463
matchTimes++
464464
}
465465
case "paths":
466-
filesChanged, err := headCommit.GetFilesChangedSinceCommit(prPayload.PullRequest.Base.Ref)
466+
filesChanged, err := headCommit.GetFilesChangedSinceCommit(prPayload.PullRequest.MergeBase)
467467
if err != nil {
468468
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", headCommit.ID.String(), err)
469469
} else {
@@ -476,7 +476,7 @@ func matchPullRequestEvent(gitRepo *git.Repository, commit *git.Commit, prPayloa
476476
}
477477
}
478478
case "paths-ignore":
479-
filesChanged, err := headCommit.GetFilesChangedSinceCommit(prPayload.PullRequest.Base.Ref)
479+
filesChanged, err := headCommit.GetFilesChangedSinceCommit(prPayload.PullRequest.MergeBase)
480480
if err != nil {
481481
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", headCommit.ID.String(), err)
482482
} else {

routers/common/blockexpensive.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func isRoutePathExpensive(routePattern string) bool {
5454
"/{username}/{reponame}/{type:issues}",
5555
"/{username}/{reponame}/pulls",
5656
"/{username}/{reponame}/{type:pulls}",
57+
"/{username}/{reponame}/{type:issues|pulls}", // for 1.23 only
5758

5859
// wiki
5960
"/{username}/{reponame}/wiki/",

services/packages/rpm/repository.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ func buildPrimary(ctx context.Context, pv *packages_model.PackageVersion, pfs []
408408
files = append(files, f)
409409
}
410410
}
411-
packageVersion := fmt.Sprintf("%s-%s", pd.FileMetadata.Version, pd.FileMetadata.Release)
412411
packages = append(packages, &Package{
413412
Type: "rpm",
414413
Name: pd.Package.Name,
@@ -437,7 +436,7 @@ func buildPrimary(ctx context.Context, pv *packages_model.PackageVersion, pfs []
437436
Archive: pd.FileMetadata.ArchiveSize,
438437
},
439438
Location: Location{
440-
Href: fmt.Sprintf("package/%s/%s/%s/%s-%s.%s.rpm", pd.Package.Name, packageVersion, pd.FileMetadata.Architecture, pd.Package.Name, packageVersion, pd.FileMetadata.Architecture),
439+
Href: fmt.Sprintf("package/%s/%s/%s/%s-%s.%s.rpm", pd.Package.Name, pd.Version.Version, pd.FileMetadata.Architecture, pd.Package.Name, pd.Version.Version, pd.FileMetadata.Architecture),
441440
},
442441
Format: Format{
443442
License: pd.VersionMetadata.License,

services/webhook/discord.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"unicode/utf8"
1515

1616
webhook_model "code.gitea.io/gitea/models/webhook"
17+
"code.gitea.io/gitea/modules/base"
1718
"code.gitea.io/gitea/modules/git"
1819
"code.gitea.io/gitea/modules/json"
1920
"code.gitea.io/gitea/modules/log"
@@ -101,6 +102,13 @@ var (
101102
redColor = color("ff3232")
102103
)
103104

105+
// https://discord.com/developers/docs/resources/message#embed-object-embed-limits
106+
// Discord has some limits in place for the embeds.
107+
// According to some tests, there is no consistent limit for different character sets.
108+
// For example: 4096 ASCII letters are allowed, but only 2490 emoji characters are allowed.
109+
// To keep it simple, we currently truncate at 2000.
110+
const discordDescriptionCharactersLimit = 2000
111+
104112
type discordConvertor struct {
105113
Username string
106114
AvatarURL string
@@ -307,7 +315,7 @@ func (d discordConvertor) createPayload(s *api.User, title, text, url string, co
307315
Embeds: []DiscordEmbed{
308316
{
309317
Title: title,
310-
Description: text,
318+
Description: base.TruncateString(text, discordDescriptionCharactersLimit),
311319
URL: url,
312320
Color: color,
313321
Author: DiscordEmbedAuthor{

tests/integration/actions_trigger_test.go

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
package integration
55

66
import (
7+
"encoding/base64"
78
"fmt"
9+
"net/http"
810
"net/url"
911
"strings"
1012
"testing"
@@ -24,7 +26,9 @@ import (
2426
"code.gitea.io/gitea/modules/git"
2527
"code.gitea.io/gitea/modules/gitrepo"
2628
"code.gitea.io/gitea/modules/setting"
29+
api "code.gitea.io/gitea/modules/structs"
2730
"code.gitea.io/gitea/modules/test"
31+
"code.gitea.io/gitea/modules/util"
2832
pull_service "code.gitea.io/gitea/services/pull"
2933
release_service "code.gitea.io/gitea/services/release"
3034
repo_service "code.gitea.io/gitea/services/repository"
@@ -451,3 +455,109 @@ func TestCreateDeleteRefEvent(t *testing.T) {
451455
assert.NotNil(t, run)
452456
})
453457
}
458+
459+
func TestClosePullRequestWithPath(t *testing.T) {
460+
onGiteaRun(t, func(t *testing.T, u *url.URL) {
461+
// user2 is the owner of the base repo
462+
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
463+
user2Token := getTokenForLoggedInUser(t, loginUser(t, user2.Name), auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
464+
// user4 is the owner of the fork repo
465+
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
466+
user4Token := getTokenForLoggedInUser(t, loginUser(t, user4.Name), auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
467+
468+
// create the base repo
469+
req := NewRequestWithJSON(t, "POST", "/api/v1/user/repos", &api.CreateRepoOption{
470+
Name: "close-pull-request-with-path",
471+
Private: false,
472+
Readme: "Default",
473+
AutoInit: true,
474+
DefaultBranch: "main",
475+
}).AddTokenAuth(user2Token)
476+
resp := MakeRequest(t, req, http.StatusCreated)
477+
var apiBaseRepo api.Repository
478+
DecodeJSON(t, resp, &apiBaseRepo)
479+
baseRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: apiBaseRepo.ID})
480+
user2APICtx := NewAPITestContext(t, baseRepo.OwnerName, baseRepo.Name, auth_model.AccessTokenScopeWriteRepository)
481+
482+
// init the workflow
483+
wfTreePath := ".gitea/workflows/pull.yml"
484+
wfFileContent := `name: Pull Request
485+
on:
486+
pull_request:
487+
types:
488+
- closed
489+
paths:
490+
- 'app/**'
491+
jobs:
492+
echo:
493+
runs-on: ubuntu-latest
494+
steps:
495+
- run: echo 'Hello World'
496+
`
497+
498+
req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", baseRepo.OwnerName, baseRepo.Name, wfTreePath), &api.CreateFileOptions{
499+
FileOptions: api.FileOptions{
500+
BranchName: baseRepo.DefaultBranch,
501+
Message: "create " + wfTreePath,
502+
Author: api.Identity{
503+
Name: user2.Name,
504+
Email: user2.Email,
505+
},
506+
Committer: api.Identity{
507+
Name: user2.Name,
508+
Email: user2.Email,
509+
},
510+
Dates: api.CommitDateOptions{
511+
Author: time.Now(),
512+
Committer: time.Now(),
513+
},
514+
},
515+
ContentBase64: base64.StdEncoding.EncodeToString([]byte(wfFileContent)),
516+
}).AddTokenAuth(user2Token)
517+
MakeRequest(t, req, http.StatusCreated)
518+
519+
// user4 forks the repo
520+
req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/forks", baseRepo.OwnerName, baseRepo.Name),
521+
&api.CreateForkOption{
522+
Name: util.ToPointer("close-pull-request-with-path-fork"),
523+
}).AddTokenAuth(user4Token)
524+
resp = MakeRequest(t, req, http.StatusAccepted)
525+
var apiForkRepo api.Repository
526+
DecodeJSON(t, resp, &apiForkRepo)
527+
forkRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: apiForkRepo.ID})
528+
user4APICtx := NewAPITestContext(t, user4.Name, forkRepo.Name, auth_model.AccessTokenScopeWriteRepository)
529+
530+
// user4 creates a pull request to add file "app/main.go"
531+
doAPICreateFile(user4APICtx, "app/main.go", &api.CreateFileOptions{
532+
FileOptions: api.FileOptions{
533+
NewBranchName: "user4/add-main",
534+
Message: "create main.go",
535+
Author: api.Identity{
536+
Name: user4.Name,
537+
Email: user4.Email,
538+
},
539+
Committer: api.Identity{
540+
Name: user4.Name,
541+
Email: user4.Email,
542+
},
543+
Dates: api.CommitDateOptions{
544+
Author: time.Now(),
545+
Committer: time.Now(),
546+
},
547+
},
548+
ContentBase64: base64.StdEncoding.EncodeToString([]byte("// main.go")),
549+
})(t)
550+
apiPull, err := doAPICreatePullRequest(user4APICtx, baseRepo.OwnerName, baseRepo.Name, baseRepo.DefaultBranch, user4.Name+":user4/add-main")(t)
551+
assert.NoError(t, err)
552+
553+
doAPIMergePullRequest(user2APICtx, baseRepo.OwnerName, baseRepo.Name, apiPull.Index)(t)
554+
555+
pullRequest := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: apiPull.ID})
556+
557+
// load and compare ActionRun
558+
assert.Equal(t, 1, unittest.GetCount(t, &actions_model.ActionRun{RepoID: baseRepo.ID}))
559+
actionRun := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{RepoID: baseRepo.ID})
560+
assert.Equal(t, actions_module.GithubEventPullRequest, actionRun.TriggerEvent)
561+
assert.Equal(t, pullRequest.MergedCommitID, actionRun.CommitSHA)
562+
})
563+
}

0 commit comments

Comments
 (0)