MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / githubUnlinkCmd

Function githubUnlinkCmd

cmd/pad/cmd_github.go:374–419  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

372}
373
374func githubUnlinkCmd() *cobra.Command {
375 return &cobra.Command{
376 Use: "unlink <item-ref>",
377 Short: "Remove the GitHub PR link from an item",
378 Example: ` pad github unlink TASK-5`,
379 Args: cobra.ExactArgs(1),
380 RunE: func(cmd *cobra.Command, args []string) error {
381 client, _ := getClient()
382 ws := getWorkspace()
383
384 item, err := client.GetItem(ws, args[0])
385 if err != nil {
386 return err
387 }
388
389 var fieldsMap map[string]interface{}
390 if err := json.Unmarshal([]byte(item.Fields), &fieldsMap); err != nil {
391 return fmt.Errorf("failed to parse item fields: %w", err)
392 }
393
394 if _, ok := fieldsMap["github_pr"]; !ok {
395 return fmt.Errorf("item %q has no linked PR", args[0])
396 }
397
398 // BUG-3049: delete the one key, not rewrite the blob. Since
399 // BUG-2696 through the typed clear_github_pr member (fields_patch
400 // refuses the key); the server lowers it to a patch DELETE. The
401 // decode above stays: it is how "has no linked PR" is detected.
402 updated, err := client.UpdateItem(ws, item.Slug, models.ItemUpdate{ClearGitHubPR: true})
403 if err != nil {
404 return err
405 }
406 if err := verifyPRUnlinked(updated); err != nil {
407 return err
408 }
409
410 green := color.New(color.FgGreen, color.Bold)
411 if formatFlag == "json" {
412 outputJSON(updated)
413 return nil
414 }
415 green.Printf("✓ Removed PR link from %s %q\n", cli.ItemRef(*item), item.Title)
416 return nil
417 },
418 }
419}
420
421// Helper functions for GitHub integration
422

Calls 8

ItemRefFunction · 0.92
getClientFunction · 0.85
getWorkspaceFunction · 0.85
verifyPRUnlinkedFunction · 0.85
outputJSONFunction · 0.85
PrintfMethod · 0.80
GetItemMethod · 0.45
UpdateItemMethod · 0.45