(opts *DevelopOptions, apiClient *api.Client, issueRepo ghrepo.Interface, issue *api.Issue)
| 176 | } |
| 177 | |
| 178 | func developRunCreate(opts *DevelopOptions, apiClient *api.Client, issueRepo ghrepo.Interface, issue *api.Issue) error { |
| 179 | branchRepo := issueRepo |
| 180 | if opts.BranchRepo != "" { |
| 181 | var err error |
| 182 | branchRepo, err = ghrepo.FromFullName(opts.BranchRepo) |
| 183 | if err != nil { |
| 184 | return err |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | opts.IO.StartProgressIndicatorWithLabel("Preparing linked branch") |
| 189 | defer opts.IO.StopProgressIndicator() |
| 190 | |
| 191 | branchName := "" |
| 192 | reusedExisting := false |
| 193 | if opts.Name != "" { |
| 194 | opts.IO.StartProgressIndicatorWithLabel("Checking existing linked branches") |
| 195 | branches, err := api.ListLinkedBranches(apiClient, issueRepo, issue.Number) |
| 196 | if err != nil { |
| 197 | return err |
| 198 | } |
| 199 | branchName = findExistingLinkedBranchName(branches, branchRepo, opts.Name) |
| 200 | reusedExisting = branchName != "" |
| 201 | } |
| 202 | |
| 203 | repoID := "" |
| 204 | branchID := "" |
| 205 | baseValidated := false |
| 206 | if opts.BaseBranch != "" { |
| 207 | opts.IO.StartProgressIndicatorWithLabel(fmt.Sprintf("Validating base branch %q", opts.BaseBranch)) |
| 208 | foundRepoID, foundBranchID, err := api.FindRepoBranchID(apiClient, branchRepo, opts.BaseBranch) |
| 209 | if err != nil { |
| 210 | return err |
| 211 | } |
| 212 | repoID = foundRepoID |
| 213 | branchID = foundBranchID |
| 214 | baseValidated = true |
| 215 | } |
| 216 | |
| 217 | if branchName == "" { |
| 218 | if !baseValidated { |
| 219 | opts.IO.StartProgressIndicatorWithLabel("Resolving base branch") |
| 220 | foundRepoID, foundBranchID, err := api.FindRepoBranchID(apiClient, branchRepo, opts.BaseBranch) |
| 221 | if err != nil { |
| 222 | return err |
| 223 | } |
| 224 | repoID = foundRepoID |
| 225 | branchID = foundBranchID |
| 226 | } |
| 227 | |
| 228 | opts.IO.StartProgressIndicatorWithLabel("Creating linked branch") |
| 229 | createdBranchName, err := api.CreateLinkedBranch(apiClient, branchRepo.RepoHost(), repoID, issue.ID, branchID, opts.Name) |
| 230 | if err != nil { |
| 231 | return err |
| 232 | } |
| 233 | branchName = createdBranchName |
| 234 | } |
| 235 |
no test coverage detected