You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-11-23 21:44:44 +02:00
Fix pipeline purge cli command (#4569)
This commit is contained in:
@@ -96,13 +96,13 @@ func pipelinePurge(c *cli.Command, client woodpecker.Client) (err error) {
|
||||
// Create a map of pipeline IDs to keep
|
||||
keepMap := make(map[int64]struct{})
|
||||
for _, p := range pipelinesKeep {
|
||||
keepMap[p.ID] = struct{}{}
|
||||
keepMap[p.Number] = struct{}{}
|
||||
}
|
||||
|
||||
// Filter pipelines to only include those not in keepMap
|
||||
var pipelinesToPurge []*woodpecker.Pipeline
|
||||
for _, p := range pipelines {
|
||||
if _, exists := keepMap[p.ID]; !exists {
|
||||
if _, exists := keepMap[p.Number]; !exists {
|
||||
pipelinesToPurge = append(pipelinesToPurge, p)
|
||||
}
|
||||
}
|
||||
@@ -114,12 +114,12 @@ func pipelinePurge(c *cli.Command, client woodpecker.Client) (err error) {
|
||||
|
||||
for i, p := range pipelinesToPurge {
|
||||
// cspell:words spurge
|
||||
log.Debug().Msgf("%spurge %v/%v pipelines from repo '%v'", msgPrefix, i+1, len(pipelinesToPurge), repoIDOrFullName)
|
||||
log.Debug().Msgf("%spurge %v/%v pipelines from repo '%v' (pipeline %v)", msgPrefix, i+1, len(pipelinesToPurge), repoIDOrFullName, p.Number)
|
||||
if dryRun {
|
||||
continue
|
||||
}
|
||||
|
||||
err := client.PipelineDelete(repoID, p.ID)
|
||||
err := client.PipelineDelete(repoID, p.Number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func fetchPipelines(client woodpecker.Client, repoID int64, duration time.Durati
|
||||
ListOptions: woodpecker.ListOptions{
|
||||
Page: page,
|
||||
},
|
||||
After: time.Now().Add(-duration),
|
||||
Before: time.Now().Add(-duration),
|
||||
},
|
||||
)
|
||||
}, -1)
|
||||
|
||||
Reference in New Issue
Block a user