@@ -214,11 +214,12 @@ func editRun(opts *EditOptions) error {
214214
215215 // Remove a file from the gist
216216 if opts .RemoveFilename != "" {
217- err := removeFile (gistToUpdate , opts .RemoveFilename )
217+ files , err := getFilesToRemove (gistToUpdate , opts .RemoveFilename )
218218 if err != nil {
219219 return err
220220 }
221221
222+ gistToUpdate .Files = files
222223 return updateGist (apiClient , host , gistToUpdate )
223224 }
224225
@@ -339,6 +340,12 @@ func editRun(opts *EditOptions) error {
339340 return nil
340341 }
341342
343+ updatedFiles := make (map [string ]* gistFileToUpdate , len (filesToUpdate ))
344+ for filename := range filesToUpdate {
345+ updatedFiles [filename ] = gistToUpdate .Files [filename ]
346+ }
347+ gistToUpdate .Files = updatedFiles
348+
342349 return updateGist (apiClient , host , gistToUpdate )
343350}
344351
@@ -396,11 +403,13 @@ func getFilesToAdd(file string, content []byte) (map[string]*gistFileToUpdate, e
396403 }, nil
397404}
398405
399- func removeFile (gist gistToUpdate , filename string ) error {
406+ func getFilesToRemove (gist gistToUpdate , filename string ) ( map [ string ] * gistFileToUpdate , error ) {
400407 if _ , found := gist .Files [filename ]; ! found {
401- return fmt .Errorf ("gist has no file %q" , filename )
408+ return nil , fmt .Errorf ("gist has no file %q" , filename )
402409 }
403410
404411 gist .Files [filename ] = nil
405- return nil
412+ return map [string ]* gistFileToUpdate {
413+ filename : nil ,
414+ }, nil
406415}
0 commit comments