Have List suggest -W for duplicate jobs (#691)
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
60b9606fc6
commit
764263ce0e
14
cmd/list.go
14
cmd/list.go
|
@ -21,17 +21,26 @@ func printList(plan *model.Plan) error {
|
||||||
name: "Name",
|
name: "Name",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jobs := map[string]bool{}
|
||||||
|
duplicateJobIDs := false
|
||||||
|
|
||||||
idMaxWidth := len(header.id)
|
idMaxWidth := len(header.id)
|
||||||
stageMaxWidth := len(header.stage)
|
stageMaxWidth := len(header.stage)
|
||||||
nameMaxWidth := len(header.name)
|
nameMaxWidth := len(header.name)
|
||||||
|
|
||||||
for i, stage := range plan.Stages {
|
for i, stage := range plan.Stages {
|
||||||
for _, r := range stage.Runs {
|
for _, r := range stage.Runs {
|
||||||
|
jobID := r.JobID
|
||||||
line := lineInfoDef{
|
line := lineInfoDef{
|
||||||
id: r.JobID,
|
id: jobID,
|
||||||
stage: strconv.Itoa(i),
|
stage: strconv.Itoa(i),
|
||||||
name: r.String(),
|
name: r.String(),
|
||||||
}
|
}
|
||||||
|
if _, ok := jobs[jobID]; ok {
|
||||||
|
duplicateJobIDs = true
|
||||||
|
} else {
|
||||||
|
jobs[jobID] = true
|
||||||
|
}
|
||||||
lineInfos = append(lineInfos, line)
|
lineInfos = append(lineInfos, line)
|
||||||
if idMaxWidth < len(line.id) {
|
if idMaxWidth < len(line.id) {
|
||||||
idMaxWidth = len(line.id)
|
idMaxWidth = len(line.id)
|
||||||
|
@ -53,5 +62,8 @@ func printList(plan *model.Plan) error {
|
||||||
for _, line := range lineInfos {
|
for _, line := range lineInfos {
|
||||||
fmt.Printf("%*s%*s%*s\n", -idMaxWidth, line.id, -stageMaxWidth, line.stage, -nameMaxWidth, line.name)
|
fmt.Printf("%*s%*s%*s\n", -idMaxWidth, line.id, -stageMaxWidth, line.stage, -nameMaxWidth, line.name)
|
||||||
}
|
}
|
||||||
|
if duplicateJobIDs {
|
||||||
|
fmt.Print("\nDetected multiple jobs with the same job name, use `-W` to specify the path to the specific workflow.\n")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue