From 96141989bee9016fee749dc2994ea7d1b5b7e5f7 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 29 Jun 2016 16:25:58 +0300 Subject: [PATCH] github: forbid creating gists from binary files it is not supported by GitHub API --- .../jetbrains/plugins/github/GithubCreateGistAction.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java index 62d3cc04ab6b..68cb51c02905 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java @@ -118,6 +118,8 @@ public class GithubCreateGistAction extends DumbAwareAction { @Override public void run(@NotNull ProgressIndicator indicator) { List 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);