@@ -35,6 +35,8 @@ type GenOpts struct {
35
35
HideIsolated bool
36
36
HidePRs bool
37
37
HideExternalDeps bool
38
+ Scope string
39
+ ScopeSize int
38
40
}
39
41
40
42
func Gen (h * cayley.Handle , args []string , opts GenOpts ) error {
@@ -50,87 +52,97 @@ func Gen(h *cayley.Handle, args []string, opts GenOpts) error {
50
52
return fmt .Errorf ("parse targets: %w" , err )
51
53
}
52
54
53
- if ! opts .NoGraph { // nolint:nestif
54
- // load tasks
55
- filters := dvmodel.Filters {
56
- Targets : targets ,
57
- WithClosed : opts .ShowClosed ,
58
- WithoutIsolated : opts .HideIsolated ,
59
- WithoutPRs : opts .HidePRs ,
60
- WithoutExternalDeps : opts .HideExternalDeps ,
61
- }
62
- tasks , err := dvstore .LoadTasks (h , opts .Schema , filters , opts .Logger )
55
+ var scope multipmuri.Entity
56
+ if opts .Scope != "" {
57
+ scope , err = dvparser .ParseTarget (opts .Scope )
63
58
if err != nil {
64
59
return fmt .Errorf ("load tasks: %w" , err )
65
60
}
61
+ }
66
62
67
- // graph
68
- pertConfig := graphmanPertConfig (tasks , opts )
69
-
70
- switch opts .Format {
71
- case "json" :
72
- return genJSON (tasks )
73
- case "csv" :
74
- return genCSV (tasks )
75
- case "graphman-pert" :
76
- out , err := yaml .Marshal (pertConfig )
77
- if err != nil {
78
- return err
79
- }
80
- fmt .Println (string (out ))
81
- return nil
82
- // TODO: fix many issues with generated dependencies
83
- //case "dot":
84
- // // graph from PERT config
85
- // graph := graphman.FromPertConfig(*pertConfig)
86
- //
87
- // // initialize graph from config
88
- // if !opts.NoPert {
89
- // result := graphman.ComputePert(graph)
90
- // shortestPath, distance := graph.FindShortestPath("Start", "Finish")
91
- // opts.Logger.Debug("pert result", zap.Any("result", result), zap.Int64("distance", distance))
92
- //
93
- // for _, edge := range shortestPath {
94
- // edge.Dst().SetColor("red")
95
- // edge.SetColor("red")
96
- // }
97
- // }
98
- //
99
- // // graph fine tuning
100
- // graph.GetVertex("Start").SetColor("blue")
101
- // graph.GetVertex("Finish").SetColor("blue")
102
- // if opts.Vertical {
103
- // graph.Attrs["rankdir"] = "TB"
104
- // }
105
- // graph.Attrs["overlap"] = "false"
106
- // graph.Attrs["pack"] = "true"
107
- // graph.Attrs["splines"] = "true"
108
- // graph.Attrs["sep"] = "0.1"
109
- // // graph.Attrs["layout"] = "neato"
110
- // // graph.Attrs["size"] = "\"11,11\""
111
- // // graph.Attrs["start"] = "random"
112
- // // FIXME: hightlight critical paths
113
- // // FIXME: highlight other infos
114
- // // FIXME: highlight target
115
- //
116
- // // graphviz
117
- // s, err := viz.ToGraphviz(graph, &viz.Opts{
118
- // CommentsInLabel: true,
119
- // })
120
- // if err != nil {
121
- // return fmt.Errorf("graphviz: %w", err)
122
- // }
123
- //
124
- // fmt.Println(s)
125
- // return nil
126
- case "quads" :
127
- return fmt .Errorf ("not implemented" )
128
- default :
129
- return fmt .Errorf ("unsupported graph format: %q" , opts .Format )
130
- }
63
+ if opts .NoGraph { // nolint:nestif
64
+ return nil
131
65
}
132
66
133
- return nil
67
+ // load tasks
68
+ filters := dvmodel.Filters {
69
+ Targets : targets ,
70
+ WithClosed : opts .ShowClosed ,
71
+ WithoutIsolated : opts .HideIsolated ,
72
+ WithoutPRs : opts .HidePRs ,
73
+ WithoutExternalDeps : opts .HideExternalDeps ,
74
+ Scope : scope ,
75
+ ScopeSize : opts .ScopeSize ,
76
+ }
77
+ tasks , err := dvstore .LoadTasks (h , opts .Schema , filters , opts .Logger )
78
+ if err != nil {
79
+ return fmt .Errorf ("load tasks: %w" , err )
80
+ }
81
+
82
+ // graph
83
+ pertConfig := graphmanPertConfig (tasks , opts )
84
+
85
+ switch opts .Format {
86
+ case "json" :
87
+ return genJSON (tasks )
88
+ case "csv" :
89
+ return genCSV (tasks )
90
+ case "graphman-pert" :
91
+ out , err := yaml .Marshal (pertConfig )
92
+ if err != nil {
93
+ return err
94
+ }
95
+ fmt .Println (string (out ))
96
+ return nil
97
+ // TODO: fix many issues with generated dependencies
98
+ //case "dot":
99
+ // // graph from PERT config
100
+ // graph := graphman.FromPertConfig(*pertConfig)
101
+ //
102
+ // // initialize graph from config
103
+ // if !opts.NoPert {
104
+ // result := graphman.ComputePert(graph)
105
+ // shortestPath, distance := graph.FindShortestPath("Start", "Finish")
106
+ // opts.Logger.Debug("pert result", zap.Any("result", result), zap.Int64("distance", distance))
107
+ //
108
+ // for _, edge := range shortestPath {
109
+ // edge.Dst().SetColor("red")
110
+ // edge.SetColor("red")
111
+ // }
112
+ // }
113
+ //
114
+ // // graph fine tuning
115
+ // graph.GetVertex("Start").SetColor("blue")
116
+ // graph.GetVertex("Finish").SetColor("blue")
117
+ // if opts.Vertical {
118
+ // graph.Attrs["rankdir"] = "TB"
119
+ // }
120
+ // graph.Attrs["overlap"] = "false"
121
+ // graph.Attrs["pack"] = "true"
122
+ // graph.Attrs["splines"] = "true"
123
+ // graph.Attrs["sep"] = "0.1"
124
+ // // graph.Attrs["layout"] = "neato"
125
+ // // graph.Attrs["size"] = "\"11,11\""
126
+ // // graph.Attrs["start"] = "random"
127
+ // // FIXME: hightlight critical paths
128
+ // // FIXME: highlight other infos
129
+ // // FIXME: highlight target
130
+ //
131
+ // // graphviz
132
+ // s, err := viz.ToGraphviz(graph, &viz.Opts{
133
+ // CommentsInLabel: true,
134
+ // })
135
+ // if err != nil {
136
+ // return fmt.Errorf("graphviz: %w", err)
137
+ // }
138
+ //
139
+ // fmt.Println(s)
140
+ // return nil
141
+ case "quads" :
142
+ return fmt .Errorf ("not implemented" )
143
+ default :
144
+ return fmt .Errorf ("unsupported graph format: %q" , opts .Format )
145
+ }
134
146
}
135
147
136
148
func pullBatches (targets []multipmuri.Entity , h * cayley.Handle , githubToken string , resync bool , logger * zap.Logger ) []dvmodel.Batch {
0 commit comments