Bug Fixes (#470)
* fix: Restore buffer local settings outside reviewer (#446) * fix: do not show healthcheck alert for warnings (#468) * feat: Add MR URL to the summary details (#467) * fix: make cycling reviewed files faster (#474) * feat(pipeline): display trigger jobs for a pipeline in the pipelines popup (#465) * fix: Jumping to renamed files (#484) --------- Co-authored-by: Jakub F. Bortlík <jakub.bortlik@proton.me> Co-authored-by: Ashish Alex <ashish.alex10@gmail.com>
This commit is contained in:
committed by
GitHub
parent
3b396a5e6b
commit
9f898aa1a8
@@ -42,19 +42,13 @@ type RequestWithPosition interface {
|
||||
func buildCommentPosition(commentWithPositionData RequestWithPosition) *gitlab.PositionOptions {
|
||||
positionData := commentWithPositionData.GetPositionData()
|
||||
|
||||
// If the file has been renamed, then this is a relevant part of the payload
|
||||
oldFileName := positionData.OldFileName
|
||||
if oldFileName == "" {
|
||||
oldFileName = positionData.FileName
|
||||
}
|
||||
|
||||
opt := &gitlab.PositionOptions{
|
||||
PositionType: &positionData.Type,
|
||||
StartSHA: &positionData.StartCommitSHA,
|
||||
HeadSHA: &positionData.HeadCommitSHA,
|
||||
BaseSHA: &positionData.BaseCommitSHA,
|
||||
NewPath: &positionData.FileName,
|
||||
OldPath: &oldFileName,
|
||||
OldPath: &positionData.OldFileName,
|
||||
NewLine: positionData.NewLine,
|
||||
OldLine: positionData.OldLine,
|
||||
}
|
||||
|
||||
@@ -20,16 +20,18 @@ type RetriggerPipelineResponse struct {
|
||||
type PipelineWithJobs struct {
|
||||
Jobs []*gitlab.Job `json:"jobs"`
|
||||
LatestPipeline *gitlab.PipelineInfo `json:"latest_pipeline"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type GetPipelineAndJobsResponse struct {
|
||||
SuccessResponse
|
||||
Pipeline PipelineWithJobs `json:"latest_pipeline"`
|
||||
Pipelines []PipelineWithJobs `json:"latest_pipeline"`
|
||||
}
|
||||
|
||||
type PipelineManager interface {
|
||||
ListProjectPipelines(pid interface{}, opt *gitlab.ListProjectPipelinesOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.PipelineInfo, *gitlab.Response, error)
|
||||
ListPipelineJobs(pid interface{}, pipelineID int, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Job, *gitlab.Response, error)
|
||||
ListPipelineBridges(pid interface{}, pipelineID int, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Bridge, *gitlab.Response, error)
|
||||
RetryPipelineBuild(pid interface{}, pipeline int, options ...gitlab.RequestOptionFunc) (*gitlab.Pipeline, *gitlab.Response, error)
|
||||
}
|
||||
|
||||
@@ -101,7 +103,6 @@ func (a pipelineService) GetPipelineAndJobs(w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
|
||||
jobs, res, err := a.client.ListPipelineJobs(a.projectInfo.ProjectId, pipeline.ID, &gitlab.ListJobsOptions{})
|
||||
|
||||
if err != nil {
|
||||
handleError(w, err, "Could not get pipeline jobs", http.StatusInternalServerError)
|
||||
return
|
||||
@@ -112,13 +113,51 @@ func (a pipelineService) GetPipelineAndJobs(w http.ResponseWriter, r *http.Reque
|
||||
return
|
||||
}
|
||||
|
||||
pipelines := []PipelineWithJobs{}
|
||||
pipelines = append(pipelines, PipelineWithJobs{
|
||||
Jobs: jobs,
|
||||
LatestPipeline: pipeline,
|
||||
Name: "root",
|
||||
})
|
||||
|
||||
bridges, res, err := a.client.ListPipelineBridges(a.projectInfo.ProjectId, pipeline.ID, &gitlab.ListJobsOptions{})
|
||||
|
||||
if err != nil {
|
||||
handleError(w, err, "Could not get pipeline trigger jobs", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if res.StatusCode >= 300 {
|
||||
handleError(w, GenericError{r.URL.Path}, "Could not get pipeline trigger jobs", res.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
for _, bridge := range bridges {
|
||||
if bridge.DownstreamPipeline == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
pipelineIdInBridge := bridge.DownstreamPipeline.ID
|
||||
bridgePipelineJobs, res, err := a.client.ListPipelineJobs(bridge.DownstreamPipeline.ProjectID, pipelineIdInBridge, &gitlab.ListJobsOptions{})
|
||||
if err != nil {
|
||||
handleError(w, err, "Could not get jobs for a pipeline from a trigger job", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if res.StatusCode >= 300 {
|
||||
handleError(w, GenericError{r.URL.Path}, "Could not get jobs for a pipeline from a trigger job", res.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
pipelines = append(pipelines, PipelineWithJobs{
|
||||
Jobs: bridgePipelineJobs,
|
||||
LatestPipeline: bridge.DownstreamPipeline,
|
||||
Name: bridge.Name,
|
||||
})
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
response := GetPipelineAndJobsResponse{
|
||||
SuccessResponse: SuccessResponse{Message: "Pipeline retrieved"},
|
||||
Pipeline: PipelineWithJobs{
|
||||
LatestPipeline: pipeline,
|
||||
Jobs: jobs,
|
||||
},
|
||||
Pipelines: pipelines,
|
||||
}
|
||||
|
||||
err = json.NewEncoder(w).Encode(response)
|
||||
|
||||
@@ -27,6 +27,14 @@ func (f fakePipelineManager) ListPipelineJobs(pid interface{}, pipelineID int, o
|
||||
return []*gitlab.Job{}, resp, err
|
||||
}
|
||||
|
||||
func (f fakePipelineManager) ListPipelineBridges(pid interface{}, pipelineID int, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Bridge, *gitlab.Response, error) {
|
||||
resp, err := f.handleGitlabError()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return []*gitlab.Bridge{}, resp, err
|
||||
}
|
||||
|
||||
func (f fakePipelineManager) RetryPipelineBuild(pid interface{}, pipeline int, options ...gitlab.RequestOptionFunc) (*gitlab.Pipeline, *gitlab.Response, error) {
|
||||
resp, err := f.handleGitlabError()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user