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.
This commit is contained in:
parent
921a2993ab
commit
943dcef478
2 changed files with 17 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue