this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pr: add spinner to pr create

authored by

Tim Culverhouse and committed by
Tangled
a0e42b79 01a9b80b

+17 -7
+17 -7
pr/create.go
··· 1 1 package pr 2 2 3 3 import ( 4 + "context" 4 5 "errors" 5 6 "fmt" 6 - "io" 7 7 "net/http" 8 8 "net/url" 9 9 "path" 10 10 "strings" 11 + "sync" 11 12 12 13 "github.com/charmbracelet/huh" 14 + "github.com/charmbracelet/huh/spinner" 13 15 "github.com/spf13/cobra" 14 16 "github.com/zalando/go-keyring" 15 17 "tangled.sh/rockorager.dev/knit" ··· 98 100 Path: path.Join(p, "/pulls/new"), 99 101 } 100 102 103 + ctx, stop := context.WithCancel(cmd.Context()) 104 + defer stop() 105 + wg := &sync.WaitGroup{} 106 + wg.Add(1) 107 + go func(wg *sync.WaitGroup) { 108 + spinner.New(). 109 + Context(ctx). 110 + Title("Creating PR..."). 111 + Run() 112 + wg.Done() 113 + }(wg) 114 + 101 115 resp, err := client.Post( 102 116 u.String(), 103 117 "application/x-www-form-urlencoded", ··· 112 126 return fmt.Errorf("unexpected status code: %d", resp.StatusCode) 113 127 } 114 128 115 - b, err := io.ReadAll(resp.Body) 116 - if err != nil { 117 - return err 118 - } 119 - 120 - fmt.Println(string(b)) 129 + stop() 130 + wg.Wait() 121 131 122 132 return nil 123 133 }