@@ -19,7 +19,6 @@ import (
1919 auth_model "code.gitea.io/gitea/models/auth"
2020 git_model "code.gitea.io/gitea/models/git"
2121 issues_model "code.gitea.io/gitea/models/issues"
22- "code.gitea.io/gitea/models/perm"
2322 pull_model "code.gitea.io/gitea/models/pull"
2423 repo_model "code.gitea.io/gitea/models/repo"
2524 "code.gitea.io/gitea/models/unittest"
@@ -34,6 +33,7 @@ import (
3433 api "code.gitea.io/gitea/modules/structs"
3534 "code.gitea.io/gitea/modules/test"
3635 "code.gitea.io/gitea/modules/translation"
36+ "code.gitea.io/gitea/modules/util"
3737 "code.gitea.io/gitea/services/automerge"
3838 "code.gitea.io/gitea/services/automergequeue"
3939 pull_service "code.gitea.io/gitea/services/pull"
@@ -1186,20 +1186,9 @@ func TestPullSquashMessage(t *testing.T) {
11861186 onGiteaRun (t , func (t * testing.T , giteaURL * url.URL ) {
11871187 user2 := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : 2 })
11881188 user2Session := loginUser (t , user2 .Name )
1189- user4 := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : 4 })
1190- user4Session := loginUser (t , user4 .Name )
11911189
1192- sessions := map [string ]* TestSession {
1193- user2 .Name : user2Session ,
1194- user4 .Name : user4Session ,
1195- }
1196-
1197- // Enable POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES
1198- resetFunc1 := test .MockVariableValue (& setting .Repository .PullRequest .PopulateSquashCommentWithCommitMessages , true )
1199- defer resetFunc1 ()
1200- // Set DEFAULT_MERGE_MESSAGE_SIZE
1201- resetFunc2 := test .MockVariableValue (& setting .Repository .PullRequest .DefaultMergeMessageSize , 512 )
1202- defer resetFunc2 ()
1190+ defer test .MockVariableValue (& setting .Repository .PullRequest .PopulateSquashCommentWithCommitMessages , true )()
1191+ defer test .MockVariableValue (& setting .Repository .PullRequest .DefaultMergeMessageSize , 512 )()
12031192
12041193 repo , err := repo_service .CreateRepository (t .Context (), user2 , user2 , repo_service.CreateRepoOptions {
12051194 Name : "squash-message-test" ,
@@ -1209,7 +1198,6 @@ func TestPullSquashMessage(t *testing.T) {
12091198 DefaultBranch : "main" ,
12101199 })
12111200 assert .NoError (t , err )
1212- doAPIAddCollaborator (NewAPITestContext (t , repo .OwnerName , repo .Name , auth_model .AccessTokenScopeWriteRepository ), user4 .Name , perm .AccessModeWrite )(t )
12131201
12141202 type commitInfo struct {
12151203 userName string
@@ -1280,32 +1268,32 @@ Implements a new email notification module.
12801268 {
12811269 userName : user2 .Name ,
12821270 commitSummary : "Add advanced validation logic for user onboarding" ,
1283- commitMessage : `This commit introduces a comprehensive validation layer for the user onboarding flow.
1284- The primary goal is to ensure that all input data is strictly validated before being processed by downstream services.
1271+ commitMessage : `This commit introduces a comprehensive validation layer for the user onboarding flow.
1272+ The primary goal is to ensure that all input data is strictly validated before being processed by downstream services.
12851273This improves system reliability and significantly reduces runtime exceptions in the registration pipeline.
12861274
12871275The validation logic includes:
12881276
128912771. Email format checking using RFC 5322-compliant patterns.
129012782. Username length and character limitation enforcement.
129112793. Password strength enforcement, including:
1292- - Minimum length checks
1293- - Mixed character type detection
1280+ - Minimum length checks
1281+ - Mixed character type detection
12941282 - Optional entropy-based scoring
129512834. Optional phone number validation using region-specific rules.
12961284` ,
12971285 },
12981286 },
12991287 expectedMessage : `* Add advanced validation logic for user onboarding
13001288
1301- This commit introduces a comprehensive validation layer for the user onboarding flow.
1302- The primary goal is to ensure that all input data is strictly validated before being processed by downstream services.
1289+ This commit introduces a comprehensive validation layer for the user onboarding flow.
1290+ The primary goal is to ensure that all input data is strictly validated before being processed by downstream services.
13031291This improves system reliability and significantly reduces runtime exceptions in the registration pipeline.
13041292
13051293The validation logic includes:
13061294
130712951. Email format checking using RFC 5322-compliant patterns.
1308- 2. Username length and character limitation enfor ...` ,
1296+ 2. Username length and character limitation enforceme ...` ,
13091297 },
13101298 {
13111299 name : "Test Co-authored-by" ,
@@ -1315,7 +1303,7 @@ The validation logic includes:
13151303 commitSummary : "Implement the login endpoint" ,
13161304 },
13171305 {
1318- userName : user4 . Name ,
1306+ userName : " user4" ,
13191307 commitSummary : "Validate request body" ,
13201308 },
13211309 },
13311319 }
13321320
13331321 for tcNum , tc := range testCases {
1334- branchName := "test-branch-" + strconv .Itoa (tcNum )
1335- fileName := fmt .Sprintf ("test-file-%d.txt" , tcNum )
13361322 t .Run (tc .name , func (t * testing.T ) {
1323+ branchName := "test-branch-" + strconv .Itoa (tcNum )
13371324 for infoIdx , info := range tc .commitInfos {
1338- content := "content-" + strconv .Itoa (infoIdx )
1339- if infoIdx == 0 {
1340- testCreateFileWithCommitMessage (t , sessions [info .userName ], repo .OwnerName , repo .Name , repo .DefaultBranch , branchName , fileName , content , info .commitSummary , info .commitMessage )
1341- } else {
1342- testEditFileWithCommitMessage (t , sessions [info .userName ], repo .OwnerName , repo .Name , branchName , fileName , content , info .commitSummary , info .commitMessage )
1325+ createFileOpts := createFileInBranchOptions {
1326+ CommitMessage : info .commitSummary + "\n \n " + info .commitMessage ,
1327+ CommitterName : info .userName ,
1328+ CommitterEmail : util .Iif (info .userName != "" , info .userName + "@example.com" , "" ),
1329+ OldBranch : util .Iif (infoIdx == 0 , "main" , branchName ),
1330+ NewBranch : branchName ,
13431331 }
1332+ testCreateFileInBranch (t , user2 , repo , createFileOpts , map [string ]string {"dummy-file-" + strconv .Itoa (infoIdx ): "dummy content" })
13441333 }
13451334 resp := testPullCreateDirectly (t , user2Session , createPullRequestOptions {
13461335 BaseRepoOwner : user2 .Name ,
0 commit comments