Skip to content

Commit ee8014a

Browse files
committed
Simplify progress indicators in issue develop
1 parent b38f677 commit ee8014a

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

pkg/cmd/issue/develop/develop.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,22 @@ func developRun(opts *DevelopOptions) error {
152152
return err
153153
}
154154

155-
opts.IO.StartProgressIndicator()
155+
opts.IO.StartProgressIndicatorWithLabel(fmt.Sprintf("Fetching issue #%d", opts.IssueNumber))
156+
defer opts.IO.StopProgressIndicator()
157+
156158
issue, err := shared.FindIssueOrPR(httpClient, baseRepo, opts.IssueNumber, []string{"id", "number"})
157-
opts.IO.StopProgressIndicator()
158159
if err != nil {
159160
return err
160161
}
161162

162163
apiClient := api.NewClientFromHTTP(httpClient)
163164

164-
opts.IO.StartProgressIndicator()
165+
opts.IO.StartProgressIndicatorWithLabel("Checking linked branch support")
165166
err = api.CheckLinkedBranchFeature(apiClient, baseRepo.RepoHost())
166-
opts.IO.StopProgressIndicator()
167167
if err != nil {
168168
return err
169169
}
170+
opts.IO.StopProgressIndicator()
170171

171172
if opts.List {
172173
return developRunList(opts, apiClient, baseRepo, issue)
@@ -184,12 +185,14 @@ func developRunCreate(opts *DevelopOptions, apiClient *api.Client, issueRepo ghr
184185
}
185186
}
186187

188+
opts.IO.StartProgressIndicatorWithLabel("Preparing linked branch")
189+
defer opts.IO.StopProgressIndicator()
190+
187191
branchName := ""
188192
reusedExisting := false
189193
if opts.Name != "" {
190-
opts.IO.StartProgressIndicator()
194+
opts.IO.StartProgressIndicatorWithLabel("Checking existing linked branches")
191195
branches, err := api.ListLinkedBranches(apiClient, issueRepo, issue.Number)
192-
opts.IO.StopProgressIndicator()
193196
if err != nil {
194197
return err
195198
}
@@ -201,9 +204,8 @@ func developRunCreate(opts *DevelopOptions, apiClient *api.Client, issueRepo ghr
201204
branchID := ""
202205
baseValidated := false
203206
if opts.BaseBranch != "" {
204-
opts.IO.StartProgressIndicator()
207+
opts.IO.StartProgressIndicatorWithLabel(fmt.Sprintf("Validating base branch %q", opts.BaseBranch))
205208
foundRepoID, foundBranchID, err := api.FindRepoBranchID(apiClient, branchRepo, opts.BaseBranch)
206-
opts.IO.StopProgressIndicator()
207209
if err != nil {
208210
return err
209211
}
@@ -214,19 +216,17 @@ func developRunCreate(opts *DevelopOptions, apiClient *api.Client, issueRepo ghr
214216

215217
if branchName == "" {
216218
if !baseValidated {
217-
opts.IO.StartProgressIndicator()
219+
opts.IO.StartProgressIndicatorWithLabel("Resolving base branch")
218220
foundRepoID, foundBranchID, err := api.FindRepoBranchID(apiClient, branchRepo, opts.BaseBranch)
219-
opts.IO.StopProgressIndicator()
220221
if err != nil {
221222
return err
222223
}
223224
repoID = foundRepoID
224225
branchID = foundBranchID
225226
}
226227

227-
opts.IO.StartProgressIndicator()
228+
opts.IO.StartProgressIndicatorWithLabel("Creating linked branch")
228229
createdBranchName, err := api.CreateLinkedBranch(apiClient, branchRepo.RepoHost(), repoID, issue.ID, branchID, opts.Name)
229-
opts.IO.StopProgressIndicator()
230230
if err != nil {
231231
return err
232232
}
@@ -237,6 +237,8 @@ func developRunCreate(opts *DevelopOptions, apiClient *api.Client, issueRepo ghr
237237
return fmt.Errorf("failed to create linked branch: API returned empty branch name")
238238
}
239239

240+
opts.IO.StopProgressIndicator()
241+
240242
if reusedExisting && opts.IO.IsStdoutTTY() {
241243
fmt.Fprintf(opts.IO.ErrOut, "Using existing linked branch %q\n", branchName)
242244
}
@@ -283,12 +285,14 @@ func linkedBranchRepoFromURL(branchURL string) (ghrepo.Interface, error) {
283285
}
284286

285287
func developRunList(opts *DevelopOptions, apiClient *api.Client, issueRepo ghrepo.Interface, issue *api.Issue) error {
286-
opts.IO.StartProgressIndicator()
288+
opts.IO.StartProgressIndicatorWithLabel("Fetching linked branches")
289+
defer opts.IO.StopProgressIndicator()
290+
287291
branches, err := api.ListLinkedBranches(apiClient, issueRepo, issue.Number)
288-
opts.IO.StopProgressIndicator()
289292
if err != nil {
290293
return err
291294
}
295+
opts.IO.StopProgressIndicator()
292296

293297
if len(branches) == 0 {
294298
return cmdutil.NewNoResultsError(fmt.Sprintf("no linked branches found for %s#%d", ghrepo.FullName(issueRepo), issue.Number))

0 commit comments

Comments
 (0)