()
| 320 | } |
| 321 | |
| 322 | func githubUnlinkCmd() *cobra.Command { |
| 323 | return &cobra.Command{ |
| 324 | Use: "unlink <item-ref>", |
| 325 | Short: "Remove the GitHub PR link from an item", |
| 326 | Args: cobra.ExactArgs(1), |
| 327 | RunE: func(cmd *cobra.Command, args []string) error { |
| 328 | client, _ := getClient() |
| 329 | ws := getWorkspace() |
| 330 | |
| 331 | item, err := client.GetItem(ws, args[0]) |
| 332 | if err != nil { |
| 333 | return err |
| 334 | } |
| 335 | |
| 336 | var fieldsMap map[string]interface{} |
| 337 | if err := json.Unmarshal([]byte(item.Fields), &fieldsMap); err != nil { |
| 338 | return fmt.Errorf("failed to parse item fields: %w", err) |
| 339 | } |
| 340 | |
| 341 | if _, ok := fieldsMap["github_pr"]; !ok { |
| 342 | return fmt.Errorf("item %q has no linked PR", args[0]) |
| 343 | } |
| 344 | |
| 345 | delete(fieldsMap, "github_pr") |
| 346 | fieldsJSON, _ := json.Marshal(fieldsMap) |
| 347 | fields := string(fieldsJSON) |
| 348 | |
| 349 | _, err = client.UpdateItem(ws, item.Slug, models.ItemUpdate{ |
| 350 | Fields: &fields, |
| 351 | }) |
| 352 | if err != nil { |
| 353 | return err |
| 354 | } |
| 355 | |
| 356 | green := color.New(color.FgGreen, color.Bold) |
| 357 | green.Printf("✓ Removed PR link from %s %q\n", cli.ItemRef(*item), item.Title) |
| 358 | return nil |
| 359 | }, |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | // Helper functions for GitHub integration |
| 364 |
no test coverage detected