diff --git a/pkg/cmd/gist/edit/edit.go b/pkg/cmd/gist/edit/edit.go index 554e9363d..566307b63 100644 --- a/pkg/cmd/gist/edit/edit.go +++ b/pkg/cmd/gist/edit/edit.go @@ -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 diff --git a/pkg/cmd/gist/edit/edit_test.go b/pkg/cmd/gist/edit/edit_test.go index d7fffd958..623e2c825 100644 --- a/pkg/cmd/gist/edit/edit_test.go +++ b/pkg/cmd/gist/edit/edit_test.go @@ -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 {