MCPcopy Index your code
hub / github.com/gogs/gogs / AddTestPullRequestTask

Function AddTestPullRequestTask

internal/database/pull.go:774–819  ·  view source on GitHub ↗

AddTestPullRequestTask adds new test tasks by given head/base repository and head/base branch, and generate new patch for testing as needed.

(doer *User, repoID int64, branch string, isSync bool)

Source from the content-addressed store, hash-verified

772// AddTestPullRequestTask adds new test tasks by given head/base repository and head/base branch,
773// and generate new patch for testing as needed.
774func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool) {
775 log.Trace("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests", repoID, branch)
776 prs, err := GetUnmergedPullRequestsByHeadInfo(repoID, branch)
777 if err != nil {
778 log.Error("Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err)
779 return
780 }
781
782 if isSync {
783 if err = PullRequestList(prs).LoadAttributes(); err != nil {
784 log.Error("PullRequestList.LoadAttributes: %v", err)
785 }
786
787 if err == nil {
788 for _, pr := range prs {
789 pr.Issue.PullRequest = pr
790 if err = pr.Issue.LoadAttributes(); err != nil {
791 log.Error("LoadAttributes: %v", err)
792 continue
793 }
794 if err = PrepareWebhooks(pr.Issue.Repo, HookEventTypePullRequest, &api.PullRequestPayload{
795 Action: api.HOOK_ISSUE_SYNCHRONIZED,
796 Index: pr.Issue.Index,
797 PullRequest: pr.Issue.PullRequest.APIFormat(),
798 Repository: pr.Issue.Repo.APIFormatLegacy(nil),
799 Sender: doer.APIFormat(),
800 }); err != nil {
801 log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err)
802 continue
803 }
804 }
805 }
806 }
807
808 addHeadRepoTasks(prs)
809
810 log.Trace("AddTestPullRequestTask [base_repo_id: %d, base_branch: %s]: finding pull requests", repoID, branch)
811 prs, err = GetUnmergedPullRequestsByBaseInfo(repoID, branch)
812 if err != nil {
813 log.Error("Find pull requests [base_repo_id: %d, base_branch: %s]: %v", repoID, branch, err)
814 return
815 }
816 for _, pr := range prs {
817 pr.AddToTaskQueue()
818 }
819}
820
821// checkAndUpdateStatus checks if pull request is possible to leaving checking status,
822// and set to be either conflict or mergeable.

Callers 2

TriggerTaskFunction · 0.92
MergeMethod · 0.85

Calls 10

PullRequestListTypeAlias · 0.85
PrepareWebhooksFunction · 0.85
addHeadRepoTasksFunction · 0.85
APIFormatLegacyMethod · 0.80
AddToTaskQueueMethod · 0.80
ErrorMethod · 0.45
LoadAttributesMethod · 0.45
APIFormatMethod · 0.45

Tested by

no test coverage detected