MCPcopy Create free account
hub / github.com/cli/cli / NewCmdDevelop

Function NewCmdDevelop

pkg/cmd/issue/develop/develop.go:40–165  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*DevelopOptions) error)

Source from the content-addressed store, hash-verified

38}
39
40func NewCmdDevelop(f *cmdutil.Factory, runF func(*DevelopOptions) error) *cobra.Command {
41 opts := &DevelopOptions{
42 IO: f.IOStreams,
43 HttpClient: f.HttpClient,
44 GitClient: f.GitClient,
45 BaseRepo: f.BaseRepo,
46 Remotes: f.Remotes,
47 }
48
49 cmd := &cobra.Command{
50 Use: "develop {<number> | <url>}",
51 Short: "Manage linked branches for an issue",
52 Long: heredoc.Docf(`
53 Manage linked branches for an issue.
54
55 When using the %[1]s--base%[1]s flag, the new development branch will be created from the specified
56 remote branch. The new branch will be configured as the base branch for pull requests created using
57 %[1]sgh pr create%[1]s.
58 `, "`"),
59 Example: heredoc.Doc(`
60 # List branches for issue 123
61 $ gh issue develop --list 123
62
63 # List branches for issue 123 in repo cli/cli
64 $ gh issue develop --list --repo cli/cli 123
65
66 # Create a branch for issue 123 based on the my-feature branch
67 $ gh issue develop 123 --base my-feature
68
69 # Create a branch for issue 123 and check it out
70 $ gh issue develop 123 --checkout
71
72 # Create a branch for issue 123 and check it out in a worktree
73 $ gh issue develop 123 --checkout --worktree /path/to/wt-feature
74
75 # Create a branch in repo monalisa/cli for issue 123 in repo cli/cli
76 $ gh issue develop 123 --repo cli/cli --branch-repo monalisa/cli
77 `),
78 Args: cmdutil.ExactArgs(1, "issue number or url is required"),
79 PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
80 // This is all a hack to not break the deprecated issue-repo flag.
81 // It will be removed in the near future and this hack can be removed at the same time.
82 flags := cmd.Flags()
83 if flags.Changed("issue-repo") {
84 if flags.Changed("repo") {
85 if flags.Changed("branch-repo") {
86 return cmdutil.FlagErrorf("specify only `--repo` and `--branch-repo`")
87 }
88 branchRepo, _ := flags.GetString("repo")
89 _ = flags.Set("branch-repo", branchRepo)
90 }
91 repo, _ := flags.GetString("issue-repo")
92 _ = flags.Set("repo", repo)
93 }
94 if cmd.Parent() != nil {
95 return cmd.Parent().PersistentPreRunE(cmd, args)
96 }
97 return nil

Callers 1

TestNewCmdDevelopFunction · 0.85

Calls 7

ExactArgsFunction · 0.92
FlagErrorfFunction · 0.92
MutuallyExclusiveFunction · 0.92
developRunFunction · 0.85
ChangedMethod · 0.80
ValueMethod · 0.80
SetMethod · 0.65

Tested by 1

TestNewCmdDevelopFunction · 0.68