addWorkflows handles workflow addition using pre-fetched content
(ctx context.Context, workflows []*ResolvedWorkflow, tracker *FileTracker, opts AddOptions)
| 279 | |
| 280 | // addWorkflows handles workflow addition using pre-fetched content |
| 281 | func addWorkflowsWithTracking(ctx context.Context, workflows []*ResolvedWorkflow, tracker *FileTracker, opts AddOptions) error { |
| 282 | addLog.Printf("Adding %d workflow(s) with tracking: force=%v, disableSecurityScanner=%v", len(workflows), opts.Force, opts.DisableSecurityScanner) |
| 283 | // Ensure .gitattributes is configured unless flag is set |
| 284 | if !opts.NoGitattributes { |
| 285 | addLog.Print("Configuring .gitattributes") |
| 286 | if updated, err := ensureGitAttributes(); err != nil { |
| 287 | addLog.Printf("Failed to configure .gitattributes: %v", err) |
| 288 | if opts.Verbose { |
| 289 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to update .gitattributes: %v", err))) |
| 290 | } |
| 291 | // Don't fail the entire operation if gitattributes update fails |
| 292 | } else if updated && opts.Verbose { |
| 293 | fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Configured .gitattributes")) |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | if !opts.Quiet && len(workflows) > 1 { |
| 298 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Adding %d workflow(s)...", len(workflows)))) |
| 299 | } |
| 300 | |
| 301 | // Add each workflow using pre-fetched content |
| 302 | for i, resolved := range workflows { |
| 303 | if !opts.Quiet && len(workflows) > 1 { |
| 304 | fmt.Fprintln(os.Stderr, console.FormatProgressMessage(fmt.Sprintf("Adding workflow %d/%d: %s", i+1, len(workflows), resolved.Spec.WorkflowName))) |
| 305 | } |
| 306 | |
| 307 | if err := addWorkflowWithTracking(ctx, resolved, tracker, opts); err != nil { |
| 308 | return fmt.Errorf("failed to add workflow '%s': %w", resolved.Spec.String(), err) |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | if !opts.Quiet && len(workflows) > 1 { |
| 313 | fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("Successfully added all %d workflows", len(workflows)))) |
| 314 | } |
| 315 | |
| 316 | return nil |
| 317 | } |
| 318 | |
| 319 | // addWorkflowWithTracking adds a workflow using pre-fetched content with file tracking |
| 320 | func addWorkflowWithTracking(ctx context.Context, resolved *ResolvedWorkflow, tracker *FileTracker, opts AddOptions) error { |
no test coverage detected