Skip to content

Commit 298fe33

Browse files
committed
clarify comments
1 parent 7c90cc2 commit 298fe33

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

server/events/vcs/gitlab_client.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -443,32 +443,29 @@ func (g *GitlabClient) UpdateStatus(logger logging.SimpleLogging, repo models.Re
443443
return err
444444
}
445445
if len(commitStatuses) > 0 {
446-
// Create a slice to hold all the unique pipelineIds
447446
var pipelineIds []int
448447

449-
// Loop through the map and collect unique pipelineId
448+
// Loop through the commitStatuses and collect unique pipelineId
450449
for _, commitStatus := range commitStatuses {
451-
// only add pipelineId to slices if it's not in the slices yet
452450
if !(slices.Contains(pipelineIds, commitStatus.PipelineId)) {
453451
pipelineIds = append(pipelineIds, commitStatus.PipelineId)
454452
}
455453
}
456454

457-
// Ensure that all commit statuses has identical pipeline ID reflected by only one pipeline ID
455+
// Check that all commit statuses has identical pipeline ID reflected by only one item in pipelineIds
458456
if len(pipelineIds) == 1 {
459457
logger.Info("Exactly one PipelineID found for commit %s and ref %s, setting new status PipelineID to %d", pull.HeadCommit, pull.HeadBranch, pipelineIds[0])
460458

461-
// Set the pipeline ID to the last pipeline that ran for the commit
459+
// Set the pipeline ID to the only item in pipelineIds
462460
setCommitStatusOptions.PipelineID = gitlab.Ptr(pipelineIds[0])
463-
break
464461
} else {
465462
logger.Warn("Commit %s has statuses from more than one PipelineID (ids=%v) for ref %s. Set PipelineID from the last commit status: %s", pull.HeadCommit, pipelineIds, pull.HeadBranch, commitStatuses[0].PipelineId)
466463

467-
// Set the pipeline ID to the last pipeline that ran for the commit
464+
// Set the pipeline ID from the latest commit status
468465
setCommitStatusOptions.PipelineID = gitlab.Ptr(commitStatuses[0].PipelineId)
469-
break
470466
}
471467

468+
break
472469
}
473470
if i != retries {
474471
logger.Info("No pipeline found for commit %s and ref %s, retrying in %s", pull.HeadCommit, pull.HeadBranch, delay)

0 commit comments

Comments
 (0)