@@ -11,7 +11,6 @@ import (
1111 prShared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
1212 "github.com/cli/cli/v2/pkg/cmdutil"
1313 "github.com/cli/cli/v2/pkg/iostreams"
14- "github.com/shurcooL/githubv4"
1514 "github.com/spf13/cobra"
1615)
1716
@@ -130,14 +129,15 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
130129 return cmd
131130}
132131
132+ var lookupFields = []string {"id" , "number" , "title" , "body" , "assignees" , "labels" , "projectCards" , "milestone" , "url" }
133+
133134func editRun (opts * EditOptions ) error {
134135 httpClient , err := opts .HttpClient ()
135136 if err != nil {
136137 return err
137138 }
138- apiClient := api .NewClientFromHTTP (httpClient )
139139
140- issue , repo , err := shared .IssueFromArg ( apiClient , opts .BaseRepo , opts .SelectorArg )
140+ issue , repo , err := shared .IssueFromArgWithFields ( httpClient , opts .BaseRepo , opts .SelectorArg , lookupFields )
141141 if err != nil {
142142 return err
143143 }
@@ -159,6 +159,7 @@ func editRun(opts *EditOptions) error {
159159 }
160160 }
161161
162+ apiClient := api .NewClientFromHTTP (httpClient )
162163 opts .IO .StartProgressIndicator ()
163164 err = opts .FetchOptions (apiClient , repo , & editable )
164165 opts .IO .StopProgressIndicator ()
@@ -178,7 +179,7 @@ func editRun(opts *EditOptions) error {
178179 }
179180
180181 opts .IO .StartProgressIndicator ()
181- err = updateIssue ( apiClient , repo , issue .ID , editable )
182+ err = prShared . UpdateIssue ( httpClient , repo , issue .ID , issue . IsPullRequest () , editable )
182183 opts .IO .StopProgressIndicator ()
183184 if err != nil {
184185 return err
@@ -188,64 +189,3 @@ func editRun(opts *EditOptions) error {
188189
189190 return nil
190191}
191-
192- func updateIssue (client * api.Client , repo ghrepo.Interface , id string , options prShared.Editable ) error {
193- var err error
194- params := githubv4.UpdateIssueInput {
195- ID : id ,
196- Title : ghString (options .TitleValue ()),
197- Body : ghString (options .BodyValue ()),
198- }
199- assigneeIds , err := options .AssigneeIds (client , repo )
200- if err != nil {
201- return err
202- }
203- params .AssigneeIDs = ghIds (assigneeIds )
204- labelIds , err := options .LabelIds ()
205- if err != nil {
206- return err
207- }
208- params .LabelIDs = ghIds (labelIds )
209- projectIds , err := options .ProjectIds ()
210- if err != nil {
211- return err
212- }
213- params .ProjectIDs = ghIds (projectIds )
214- milestoneId , err := options .MilestoneId ()
215- if err != nil {
216- return err
217- }
218- params .MilestoneID = ghId (milestoneId )
219- return api .IssueUpdate (client , repo , params )
220- }
221-
222- func ghIds (s * []string ) * []githubv4.ID {
223- if s == nil {
224- return nil
225- }
226- ids := make ([]githubv4.ID , len (* s ))
227- for i , v := range * s {
228- ids [i ] = v
229- }
230- return & ids
231- }
232-
233- func ghId (s * string ) * githubv4.ID {
234- if s == nil {
235- return nil
236- }
237- if * s == "" {
238- r := githubv4 .ID (nil )
239- return & r
240- }
241- r := githubv4 .ID (* s )
242- return & r
243- }
244-
245- func ghString (s * string ) * githubv4.String {
246- if s == nil {
247- return nil
248- }
249- r := githubv4 .String (* s )
250- return & r
251- }
0 commit comments