MCPcopy Create free account
hub / github.com/github/gh-aw / addWorkflowsWithTracking

Function addWorkflowsWithTracking

pkg/cli/add_command.go:281–317  ·  view source on GitHub ↗

addWorkflows handles workflow addition using pre-fetched content

(ctx context.Context, workflows []*ResolvedWorkflow, tracker *FileTracker, opts AddOptions)

Source from the content-addressed store, hash-verified

279
280// addWorkflows handles workflow addition using pre-fetched content
281func 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
320func addWorkflowWithTracking(ctx context.Context, resolved *ResolvedWorkflow, tracker *FileTracker, opts AddOptions) error {

Callers 2

addWorkflowsFunction · 0.85
addWorkflowsWithPRFunction · 0.85

Calls 10

FormatWarningMessageFunction · 0.92
FormatSuccessMessageFunction · 0.92
FormatInfoMessageFunction · 0.92
FormatProgressMessageFunction · 0.92
ensureGitAttributesFunction · 0.85
addWorkflowWithTrackingFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected