github: forbid creating gists from binary files

it is not supported by GitHub API
This commit is contained in:
Aleksey Pivovarov
2016-06-29 16:47:21 +03:00
parent 46d975f3f6
commit 96141989be
@@ -118,6 +118,8 @@ public class GithubCreateGistAction extends DumbAwareAction {
@Override
public void run(@NotNull ProgressIndicator indicator) {
List<FileContent> contents = collectContents(project, editor, file, files);
if (contents.isEmpty()) return;
String gistUrl =
createGist(project, authHolder, indicator, contents, dialog.isPrivate(), dialog.getDescription(), dialog.getFileName());
url.set(gistUrl);
@@ -237,6 +239,10 @@ public class GithubCreateGistAction extends DumbAwareAction {
if (file.isDirectory()) {
return getContentFromDirectory(file, project, prefix);
}
if (file.getFileType().isBinary()) {
GithubNotifications.showWarning(project, FAILED_TO_CREATE_GIST, "Can't upload binary file: " + file);
return Collections.emptyList();
}
String content = ReadAction.compute(() -> {
try {
Document document = FileDocumentManager.getInstance().getDocument(file);