(params *models.PullRequestParams)
| 96 | } |
| 97 | |
| 98 | func (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 | |
| 135 | func (gu *githubUsecase) PullRequestsGenerator(params interface{}) ([]uiConfigModels.GeneratedTile, error) { |
| 136 | prParams := params.(*models.PullRequestGeneratorParams) |
nothing calls this directly
no test coverage detected