MCPcopy Create free account
hub / github.com/alibaba/open-code-review / executeDelegatePreview

Function executeDelegatePreview

cmd/opencodereview/delegate_cmd.go:167–233  ·  view source on GitHub ↗
(opts delegateOptions)

Source from the content-addressed store, hash-verified

165}
166
167func executeDelegatePreview(opts delegateOptions) error {
168 dc, err := loadDelegateContext(opts)
169 if err != nil {
170 return err
171 }
172
173 ctx := context.Background()
174 preview, err := dc.preview(ctx)
175 if err != nil {
176 return fmt.Errorf("preview failed: %w", err)
177 }
178 mergeBase := dc.mergeBase(ctx)
179 if opts.format == "json" {
180 return writeDelegateJSON(delegatePreviewJSON{
181 SchemaVersion: delegateSchemaVersion,
182 Mode: dc.reviewMode(),
183 Repository: dc.cc.RepoDir,
184 From: dc.opts.from,
185 To: dc.opts.to,
186 Commit: dc.opts.commit,
187 MergeBase: mergeBase,
188 Background: dc.opts.background,
189 TotalFiles: preview.TotalFiles,
190 ReviewableCount: preview.ReviewableCount,
191 ExcludedCount: preview.ExcludedCount,
192 TotalInsertions: preview.TotalInsertions,
193 TotalDeletions: preview.TotalDeletions,
194 ReviewableFiles: previewFiles(preview, true),
195 ExcludedFiles: previewFiles(preview, false),
196 })
197 }
198
199 fmt.Printf("# Files (%d reviewable / %d total)\n\n", preview.ReviewableCount, preview.TotalFiles)
200 fmt.Printf("- mode: %s\n", dc.reviewMode())
201 if dc.opts.from != "" {
202 fmt.Printf("- from: %s\n", dc.opts.from)
203 }
204 if dc.opts.to != "" {
205 fmt.Printf("- to: %s\n", dc.opts.to)
206 }
207 if dc.opts.commit != "" {
208 fmt.Printf("- commit: %s\n", dc.opts.commit)
209 }
210 if mergeBase != "" {
211 fmt.Printf("- merge_base: %s\n", mergeBase)
212 }
213 if dc.opts.background != "" {
214 fmt.Printf("- background: %s\n", dc.opts.background)
215 }
216 fmt.Printf("- total_insertions: %d\n", preview.TotalInsertions)
217 fmt.Printf("- total_deletions: %d\n\n", preview.TotalDeletions)
218
219 for _, entry := range preview.Entries {
220 marker := " "
221 if !entry.WillReview {
222 marker = "~~"
223 }
224 fmt.Printf("%s- `%s` [%s] +%d/-%d", marker, entry.Path, entry.Status, entry.Insertions, entry.Deletions)

Calls 6

loadDelegateContextFunction · 0.85
writeDelegateJSONFunction · 0.85
previewFilesFunction · 0.85
previewMethod · 0.45
mergeBaseMethod · 0.45
reviewModeMethod · 0.45