mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 19:31:05 +00:00
CLI: remove step-id and add step-number as option to logs (#3927)
This commit is contained in:
parent
e76f1408f4
commit
7903d6f357
2 changed files with 9 additions and 17 deletions
|
@ -166,12 +166,10 @@ 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.
|
ParseStep parses the step id form a string which may either be the step PID (step number) or a step name.
|
||||||
These rules apply:
|
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.
|
- First match is used, when there are multiple steps with the same name.
|
||||||
|
|
||||||
Strictly speaking, this is not parsing, but a lookup.
|
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) {
|
func ParseStep(client woodpecker.Client, repoID, number int64, stepArg string) (stepID int64, err error) {
|
||||||
pipeline, err := client.Pipeline(repoID, number)
|
pipeline, err := client.Pipeline(repoID, number)
|
||||||
|
@ -179,12 +177,8 @@ func ParseStep(client woodpecker.Client, repoID, number int64, stepArg string) (
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
stepID, err = strconv.ParseInt(stepArg, 10, 64)
|
stepPID, err := strconv.ParseInt(stepArg, 10, 64)
|
||||||
// TODO: for 3.0 do "stepPID, err := strconv.ParseInt(stepArg, 10, 64)"
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return stepID, nil
|
|
||||||
/*
|
|
||||||
// TODO: for 3.0
|
|
||||||
for _, wf := range pipeline.Workflows {
|
for _, wf := range pipeline.Workflows {
|
||||||
for _, step := range wf.Children {
|
for _, step := range wf.Children {
|
||||||
if int64(step.PID) == stepPID {
|
if int64(step.PID) == stepPID {
|
||||||
|
@ -192,7 +186,6 @@ func ParseStep(client woodpecker.Client, repoID, number int64, stepArg string) (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, wf := range pipeline.Workflows {
|
for _, wf := range pipeline.Workflows {
|
||||||
|
|
|
@ -30,8 +30,7 @@ import (
|
||||||
var pipelineLogsCmd = &cli.Command{
|
var pipelineLogsCmd = &cli.Command{
|
||||||
Name: "logs",
|
Name: "logs",
|
||||||
Usage: "show pipeline logs",
|
Usage: "show pipeline logs",
|
||||||
ArgsUsage: "<repo-id|repo-full-name> <pipeline> [step-id|step-name]",
|
ArgsUsage: "<repo-id|repo-full-name> <pipeline> [step-number|step-name]",
|
||||||
// TODO: for v3.0 do `ArgsUsage: "<repo-id|repo-full-name> <pipeline> [step-number|step-name]",`
|
|
||||||
Action: pipelineLogs,
|
Action: pipelineLogs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue