Merge pull request #1828 from y-yagi/do-not-send-requests-when-unnecessary

Don't send a request when the contents haven't changed
This commit is contained in:
Nate Smith 2020-09-21 16:40:41 -05:00 committed by GitHub
commit 2a9b5de8c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -174,6 +174,10 @@ func editRun(opts *EditOptions) error {
}
}
if len(filesToUpdate) == 0 {
return nil
}
err = updateGist(client, ghinstance.OverridableDefault(), gist)
if err != nil {
return err

View file

@ -177,6 +177,19 @@ func Test_editRun(t *testing.T) {
},
},
},
{
name: "not change",
gist: &shared.Gist{
ID: "1234",
Files: map[string]*shared.GistFile{
"cicada.txt": {
Filename: "cicada.txt",
Content: "new file content",
Type: "text/plain",
},
},
},
},
}
for _, tt := range tests {