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