Skip to content

Commit 943dcef

Browse files
committed
Don't send a request when the contents haven't changed
By doing this, the command will finish faster if the user canceled the editing.
1 parent 921a299 commit 943dcef

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pkg/cmd/gist/edit/edit.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ func editRun(opts *EditOptions) error {
174174
}
175175
}
176176

177+
if len(filesToUpdate) == 0 {
178+
return nil
179+
}
180+
177181
err = updateGist(client, ghinstance.OverridableDefault(), gist)
178182
if err != nil {
179183
return err

pkg/cmd/gist/edit/edit_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ func Test_editRun(t *testing.T) {
177177
},
178178
},
179179
},
180+
{
181+
name: "not change",
182+
gist: &shared.Gist{
183+
ID: "1234",
184+
Files: map[string]*shared.GistFile{
185+
"cicada.txt": {
186+
Filename: "cicada.txt",
187+
Content: "new file content",
188+
Type: "text/plain",
189+
},
190+
},
191+
},
192+
},
180193
}
181194

182195
for _, tt := range tests {

0 commit comments

Comments
 (0)