Skip to content

Commit

Permalink
CLI: remove step-id and add step-number as option to logs (#3927)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 authored Jul 19, 2024
1 parent e76f140 commit 7903d6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
21 changes: 7 additions & 14 deletions cli/internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,33 +166,26 @@ func ParseKeyPair(p []string) map[string]string {
ParseStep parses the step id form a string which may either be the step PID (step number) or a step name.
These rules apply:
- Step ID take precedence over step name when searching for a match.
- Step PID take precedence over step name when searching for a match.
- First match is used, when there are multiple steps with the same name.
Strictly speaking, this is not parsing, but a lookup.
TODO: Use PID instead of StepID
*/
func ParseStep(client woodpecker.Client, repoID, number int64, stepArg string) (stepID int64, err error) {
pipeline, err := client.Pipeline(repoID, number)
if err != nil {
return 0, err
}

stepID, err = strconv.ParseInt(stepArg, 10, 64)
// TODO: for 3.0 do "stepPID, err := strconv.ParseInt(stepArg, 10, 64)"
stepPID, err := strconv.ParseInt(stepArg, 10, 64)
if err == nil {
return stepID, nil
/*
// TODO: for 3.0
for _, wf := range pipeline.Workflows {
for _, step := range wf.Children {
if int64(step.PID) == stepPID {
return step.ID, nil
}
for _, wf := range pipeline.Workflows {
for _, step := range wf.Children {
if int64(step.PID) == stepPID {
return step.ID, nil
}
}
*/
}
}

for _, wf := range pipeline.Workflows {
Expand Down
5 changes: 2 additions & 3 deletions cli/pipeline/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ import (
var pipelineLogsCmd = &cli.Command{
Name: "logs",
Usage: "show pipeline logs",
ArgsUsage: "<repo-id|repo-full-name> <pipeline> [step-id|step-name]",
// TODO: for v3.0 do `ArgsUsage: "<repo-id|repo-full-name> <pipeline> [step-number|step-name]",`
Action: pipelineLogs,
ArgsUsage: "<repo-id|repo-full-name> <pipeline> [step-number|step-name]",
Action: pipelineLogs,
}

func pipelineLogs(ctx context.Context, c *cli.Command) error {
Expand Down

0 comments on commit 7903d6f

Please sign in to comment.