MCPcopy Create free account
hub / github.com/monitoror/monitoror / PullRequest

Method PullRequest

monitorables/github/api/usecase/github.go:98–133  ·  view source on GitHub ↗
(params *models.PullRequestParams)

Source from the content-addressed store, hash-verified

96}
97
98func (gu *githubUsecase) PullRequest(params *models.PullRequestParams) (*coreModels.Tile, error) {
99 tile := coreModels.NewTile(api.GithubPullRequestTileType).WithBuild()
100
101 // Request pullRequest
102 pullRequest, err := gu.repository.GetPullRequest(params.Owner, params.Repository, *params.ID)
103 if err != nil {
104 return nil, &coreModels.MonitororError{Err: err, Tile: tile, Message: "unable to load pull request"}
105 }
106
107 tile.Label = params.Repository
108 tile.Build.Branch = pointer.ToString(git.HumanizeBranch(pullRequest.SourceBranch))
109 if params.Owner != pullRequest.SourceOwner {
110 tile.Build.Branch = pointer.ToString(fmt.Sprintf("%s:%s", pullRequest.SourceOwner, *tile.Build.Branch))
111 }
112 tile.Build.MergeRequest = &coreModels.TileMergeRequest{
113 ID: pullRequest.ID,
114 Title: pullRequest.Title,
115 }
116
117 // With pull request, we use CommitSHA as Ref on params.Owner/params.Repo to handle correctly Checks from Forks
118 // Request checks
119 checks, err := gu.repository.GetChecks(params.Owner, params.Repository, pullRequest.CommitSHA)
120 if err != nil {
121 return nil, &coreModels.MonitororError{Err: err, Tile: tile, Message: "unable to load ref checks"}
122 }
123
124 // Compute checks into tile
125 gu.computeRefChecks(tile, checks, params.String())
126
127 // Author of pull request
128 if tile.Status == coreModels.FailedStatus {
129 tile.Build.Author = &pullRequest.Author
130 }
131
132 return tile, nil
133}
134
135func (gu *githubUsecase) PullRequestsGenerator(params interface{}) ([]uiConfigModels.GeneratedTile, error) {
136 prParams := params.(*models.PullRequestGeneratorParams)

Callers

nothing calls this directly

Calls 6

computeRefChecksMethod · 0.95
HumanizeBranchFunction · 0.92
WithBuildMethod · 0.80
GetPullRequestMethod · 0.65
GetChecksMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected