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

Function developRunCreate

pkg/cmd/issue/develop/develop.go:201–288  ·  view source on GitHub ↗
(opts *DevelopOptions, apiClient *api.Client, issueRepo ghrepo.Interface, issue *api.Issue)

Source from the content-addressed store, hash-verified

199}
200
201func developRunCreate(opts *DevelopOptions, apiClient *api.Client, issueRepo ghrepo.Interface, issue *api.Issue) error {
202 branchRepo := issueRepo
203 if opts.BranchRepo != "" {
204 var err error
205 branchRepo, err = ghrepo.FromFullName(opts.BranchRepo)
206 if err != nil {
207 return err
208 }
209 }
210
211 var worktreeTarget prShared.WorktreeTarget
212 if opts.Worktree != "" {
213 var err error
214 worktreeTarget, err = prShared.ResolveWorktreeTarget(opts.GitClient, opts.Worktree)
215 if err != nil {
216 return err
217 }
218 }
219
220 opts.IO.StartProgressIndicatorWithLabel("Preparing linked branch")
221 defer opts.IO.StopProgressIndicator()
222
223 branchName := ""
224 reusedExisting := false
225 if opts.Name != "" {
226 opts.IO.StartProgressIndicatorWithLabel("Checking existing linked branches")
227 branches, err := api.ListLinkedBranches(apiClient, issueRepo, issue.Number)
228 if err != nil {
229 return err
230 }
231 branchName = findExistingLinkedBranchName(branches, branchRepo, opts.Name)
232 reusedExisting = branchName != ""
233 }
234
235 repoID := ""
236 branchID := ""
237 baseValidated := false
238 if opts.BaseBranch != "" {
239 opts.IO.StartProgressIndicatorWithLabel(fmt.Sprintf("Validating base branch %q", opts.BaseBranch))
240 foundRepoID, foundBranchID, err := api.FindRepoBranchID(apiClient, branchRepo, opts.BaseBranch)
241 if err != nil {
242 return err
243 }
244 repoID = foundRepoID
245 branchID = foundBranchID
246 baseValidated = true
247 }
248
249 if branchName == "" {
250 if !baseValidated {
251 opts.IO.StartProgressIndicatorWithLabel("Resolving base branch")
252 foundRepoID, foundBranchID, err := api.FindRepoBranchID(apiClient, branchRepo, opts.BaseBranch)
253 if err != nil {
254 return err
255 }
256 repoID = foundRepoID
257 branchID = foundBranchID
258 }

Callers 1

developRunFunction · 0.85

Calls 13

FromFullNameFunction · 0.92
ListLinkedBranchesFunction · 0.92
FindRepoBranchIDFunction · 0.92
CreateLinkedBranchFunction · 0.92
FullNameFunction · 0.92
checkoutBranchFunction · 0.85
IsStdoutTTYMethod · 0.80
SetBranchConfigMethod · 0.80
StopProgressIndicatorMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected