@@ -1072,93 +1072,6 @@ func (prs PullRequestList) InvalidateCodeComments(doer *User, repo *git.Reposito
10721072 return prs .invalidateCodeComments (x , doer , repo , branch )
10731073}
10741074
1075- func addHeadRepoTasks (prs []* PullRequest ) {
1076- for _ , pr := range prs {
1077- log .Trace ("addHeadRepoTasks[%d]: composing new test task" , pr .ID )
1078- if err := pr .UpdatePatch (); err != nil {
1079- log .Error ("UpdatePatch: %v" , err )
1080- continue
1081- } else if err := pr .PushToBaseRepo (); err != nil {
1082- log .Error ("PushToBaseRepo: %v" , err )
1083- continue
1084- }
1085-
1086- pr .AddToTaskQueue ()
1087- }
1088- }
1089-
1090- // AddTestPullRequestTask adds new test tasks by given head/base repository and head/base branch,
1091- // and generate new patch for testing as needed.
1092- func AddTestPullRequestTask (doer * User , repoID int64 , branch string , isSync bool ) {
1093- log .Trace ("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests" , repoID , branch )
1094- prs , err := GetUnmergedPullRequestsByHeadInfo (repoID , branch )
1095- if err != nil {
1096- log .Error ("Find pull requests [head_repo_id: %d, head_branch: %s]: %v" , repoID , branch , err )
1097- return
1098- }
1099-
1100- if isSync {
1101- requests := PullRequestList (prs )
1102- if err = requests .LoadAttributes (); err != nil {
1103- log .Error ("PullRequestList.LoadAttributes: %v" , err )
1104- }
1105- if invalidationErr := checkForInvalidation (requests , repoID , doer , branch ); invalidationErr != nil {
1106- log .Error ("checkForInvalidation: %v" , invalidationErr )
1107- }
1108- if err == nil {
1109- for _ , pr := range prs {
1110- pr .Issue .PullRequest = pr
1111- if err = pr .Issue .LoadAttributes (); err != nil {
1112- log .Error ("LoadAttributes: %v" , err )
1113- continue
1114- }
1115- if err = PrepareWebhooks (pr .Issue .Repo , HookEventPullRequest , & api.PullRequestPayload {
1116- Action : api .HookIssueSynchronized ,
1117- Index : pr .Issue .Index ,
1118- PullRequest : pr .Issue .PullRequest .APIFormat (),
1119- Repository : pr .Issue .Repo .APIFormat (AccessModeNone ),
1120- Sender : doer .APIFormat (),
1121- }); err != nil {
1122- log .Error ("PrepareWebhooks [pull_id: %v]: %v" , pr .ID , err )
1123- continue
1124- }
1125- go HookQueue .Add (pr .Issue .Repo .ID )
1126- }
1127- }
1128-
1129- }
1130-
1131- addHeadRepoTasks (prs )
1132-
1133- log .Trace ("AddTestPullRequestTask [base_repo_id: %d, base_branch: %s]: finding pull requests" , repoID , branch )
1134- prs , err = GetUnmergedPullRequestsByBaseInfo (repoID , branch )
1135- if err != nil {
1136- log .Error ("Find pull requests [base_repo_id: %d, base_branch: %s]: %v" , repoID , branch , err )
1137- return
1138- }
1139- for _ , pr := range prs {
1140- pr .AddToTaskQueue ()
1141- }
1142- }
1143-
1144- func checkForInvalidation (requests PullRequestList , repoID int64 , doer * User , branch string ) error {
1145- repo , err := GetRepositoryByID (repoID )
1146- if err != nil {
1147- return fmt .Errorf ("GetRepositoryByID: %v" , err )
1148- }
1149- gitRepo , err := git .OpenRepository (repo .RepoPath ())
1150- if err != nil {
1151- return fmt .Errorf ("git.OpenRepository: %v" , err )
1152- }
1153- go func () {
1154- err := requests .InvalidateCodeComments (doer , gitRepo , branch )
1155- if err != nil {
1156- log .Error ("PullRequestList.InvalidateCodeComments: %v" , err )
1157- }
1158- }()
1159- return nil
1160- }
1161-
11621075// ChangeUsernameInPullRequests changes the name of head_user_name
11631076func ChangeUsernameInPullRequests (oldUserName , newUserName string ) error {
11641077 pr := PullRequest {
0 commit comments