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

Function ensureStatusOption

pkg/cli/project_command.go:568–602  ·  view source on GitHub ↗

ensureStatusOption ensures a status option exists in the project's Status field

(ctx context.Context, projectURL, optionName string, verbose bool)

Source from the content-addressed store, hash-verified

566
567// ensureStatusOption ensures a status option exists in the project's Status field
568func ensureStatusOption(ctx context.Context, projectURL, optionName string, verbose bool) error {
569 projectLog.Printf("Ensuring Status option: %s", optionName)
570 console.LogVerbose(verbose, fmt.Sprintf("Adding '%s' status option...", optionName))
571
572 info, err := parseProjectURL(projectURL)
573 if err != nil {
574 return fmt.Errorf("failed to parse project URL: %w", err)
575 }
576
577 // Get the Status field information
578 statusField, err := getStatusField(ctx, info, verbose)
579 if err != nil {
580 return fmt.Errorf("failed to get Status field: %w", err)
581 }
582
583 // Check if the option already exists and is properly ordered
584 updatedOptions, changed := ensureSingleSelectOptionBefore(
585 statusField.options,
586 singleSelectOption{Name: optionName, Color: "BLUE", Description: "Needs review before moving to Done"},
587 "Done",
588 )
589
590 if !changed {
591 console.LogVerbose(verbose, "Status option already present and ordered: "+optionName)
592 return nil
593 }
594
595 // Update the field with new options
596 if err := updateSingleSelectFieldOptions(ctx, statusField.fieldID, updatedOptions, verbose); err != nil {
597 return fmt.Errorf("failed to update Status field: %w", err)
598 }
599
600 console.LogVerbose(verbose, "Status option added before 'Done': "+optionName)
601 return nil
602}
603
604// singleSelectOption represents a single-select field option
605type singleSelectOption struct {

Callers 1

RunProjectNewFunction · 0.85

Calls 7

LogVerboseFunction · 0.92
parseProjectURLFunction · 0.85
getStatusFieldFunction · 0.85
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected