Skip to content

Commit

Permalink
Merge pull request #36 from ahinh43/duplicate-message-posting
Browse files Browse the repository at this point in the history
Have `getLatestPipelineID` return branch pipeline ID if no merge request pipeline was found
  • Loading branch information
ahinh43 authored Aug 16, 2023
2 parents f55683f + 238f4b4 commit af18e5c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/vcs/gitlab/mr_status_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,21 @@ func (p *RunStatusUpdater) getLatestPipelineID(ctx context.Context, rmd runstrea
return nil
}
log.Trace().Interface("pipelines", pipelines).Msg("retrieved pipelines for commit")
var pipelineID *int
if len(pipelines) > 0 {
for _, p := range pipelines {
if p.GetSource() == "merge_request_event" {
return gogitlab.Int(p.GetID())
pipelineID = gogitlab.Int(p.GetID())
return pipelineID
}
}
// Fallback behavior if Gitlab doesn't find any merge request pipelines
// Returns last pipeline ID in the pipelines list
if pipelineID == nil {
log.Debug().Msg("No merge request pipeline ID found for the commit. Using latest pipeline ID as fallback...")
pipelineID = gogitlab.Int(pipelines[len(pipelines)-1].GetID())
return pipelineID
}
}
return nil
}
Expand Down

0 comments on commit af18e5c

Please sign in to comment.