mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-20 03:50:10 +00:00
refactor: use slices.Contains to simplify (#5468)
Signed-off-by: zhedazijingang <unwrap_or_else@outlook.com>
This commit is contained in:
@@ -17,6 +17,7 @@ package pipeline
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
@@ -108,13 +109,7 @@ func cancelPreviousPipelines(
|
||||
user *model.User,
|
||||
) error {
|
||||
// check this event should cancel previous pipelines
|
||||
eventIncluded := false
|
||||
for _, ev := range repo.CancelPreviousPipelineEvents {
|
||||
if ev == pipeline.Event {
|
||||
eventIncluded = true
|
||||
break
|
||||
}
|
||||
}
|
||||
eventIncluded := slices.Contains(repo.CancelPreviousPipelineEvents, pipeline.Event)
|
||||
if !eventIncluded {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user