use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.
the class GithubCreateGistTestBase method createContent.
@NotNull
protected static List<FileContent> createContent() {
List<FileContent> content = new ArrayList<>();
content.add(new FileContent("file1", "file1 content"));
content.add(new FileContent("file2", "file2 content"));
content.add(new FileContent("dir_file3", "file3 content"));
return content;
}
use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.
the class GithubCreateGistTestBase method checkGistContent.
protected void checkGistContent(@NotNull List<FileContent> expected) {
GithubGist result = getGist();
List<FileContent> files = new ArrayList<>();
for (GithubGist.GistFile file : result.getFiles()) {
files.add(new FileContent(file.getFilename(), file.getContent()));
}
assertTrue("Gist content differs from sample", Comparing.haveEqualElements(files, expected));
}
use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.
the class GithubCreateGistAction method createGist.
@Nullable
static String createGist(@NotNull Project project, @NotNull GithubAuthDataHolder auth, @NotNull ProgressIndicator indicator, @NotNull List<FileContent> contents, final boolean isPrivate, @NotNull final String description, @Nullable String filename) {
if (contents.isEmpty()) {
GithubNotifications.showWarning(project, FAILED_TO_CREATE_GIST, "Can't create empty gist");
return null;
}
if (contents.size() == 1 && filename != null) {
FileContent entry = contents.iterator().next();
contents = Collections.singletonList(new FileContent(filename, entry.getContent()));
}
try {
final List<FileContent> finalContents = contents;
return GithubUtil.runTask(project, auth, indicator, AuthLevel.ANY, connection -> GithubApiUtil.createGist(connection, finalContents, description, isPrivate)).getHtmlUrl();
} catch (IOException e) {
GithubNotifications.showError(project, FAILED_TO_CREATE_GIST, e);
return null;
}
}
use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.
the class GithubCreateGistAction method getContentFromDirectory.
@NotNull
private static List<FileContent> getContentFromDirectory(@NotNull VirtualFile dir, @NotNull Project project, @Nullable String prefix) {
List<FileContent> contents = new ArrayList<>();
for (VirtualFile file : dir.getChildren()) {
if (!isFileIgnored(file, project)) {
String pref = addPrefix(dir.getName(), prefix, true);
contents.addAll(getContentFromFile(file, project, pref));
}
}
return contents;
}
Aggregations