Skip to content

Commit f8651f5

Browse files
committed
fix(gist): fetch full content for truncated files during editing
This change makes it only fetch the raw content, when we wanna edit the specific file.
1 parent cf71803 commit f8651f5

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

pkg/cmd/gist/edit/edit.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,6 @@ func editRun(opts *EditOptions) error {
155155
// Transform our gist into the schema that the update endpoint expects
156156
filesToupdate := make(map[string]*gistFileToUpdate, len(gist.Files))
157157
for filename, file := range gist.Files {
158-
if file.Truncated {
159-
fullContent, err := shared.GetRawGistFile(client, file.RawURL)
160-
if err != nil {
161-
return err
162-
}
163-
164-
file.Content = fullContent
165-
}
166-
167158
filesToupdate[filename] = &gistFileToUpdate{
168159
Content: file.Content,
169160
NewFilename: file.Filename,
@@ -267,6 +258,17 @@ func editRun(opts *EditOptions) error {
267258
return fmt.Errorf("editing binary files not supported")
268259
}
269260

261+
// If the file is truncated, fetch the full content
262+
file := gist.Files[filename]
263+
if file.Truncated {
264+
fullContent, err := shared.GetRawGistFile(client, file.RawURL)
265+
if err != nil {
266+
return err
267+
}
268+
269+
gistFile.Content = fullContent
270+
}
271+
270272
var text string
271273
if src := opts.SourceFile; src != "" {
272274
if src == "-" {

0 commit comments

Comments
 (0)