public List<GHContent> getDirectoryContent(String path) throws IOException { return getDirectoryContent(path, null); }
public List<GHContent> getDirectoryContent(String path) throws IOException { return getDirectoryContent(path, null); }
public List<GHContent> getDirectoryContent(String path) throws IOException { return getDirectoryContent(path, null); }
private boolean isGitmodulesFileExist() throws IOException { return 0 < ghRepo .getDirectoryContent("") .stream() .filter(item -> item.getName().equals(".gitmodules")) .count(); }
/** * Delete folder with content inside the repository on GitHub. * * @param folder folder to delete * @param deleteCommitMessage commit message which is used to delete the message * @throws IOException */ public void deleteFolder(Path folder, String deleteCommitMessage) throws IOException { for (GHContent ghContent : ghRepo.getDirectoryContent(folder.toString())) { ghContent.delete(deleteCommitMessage); } }
public void modifyAllOnGithub(GHRepository repo, String branch, String img, String tag) throws IOException, InterruptedException { List<GHContent> tree = null; /* There are issues with the GitHub API returning that the GitHub repository exists, but has no content, * when we try to pull on it the moment it is created. The system must wait a short time before we can move on. */ for (int i = 0; i < 5; i++) { try { tree = repo.getDirectoryContent(".", branch); break; } catch (FileNotFoundException e1) { log.warn("Content in repository not created yet. Retrying connection to fork..."); Thread.sleep(1000); } } for (GHContent con : tree) { modifyOnGithubRecursive(repo, con, branch, img, tag); } }
public void modifyAllOnGithub(GHRepository repo, String branch, String img, String tag) throws IOException, InterruptedException { List<GHContent> tree = null; /* There are issues with the GitHub API returning that the GitHub repository exists, but has no content, * when we try to pull on it the moment it is created. The system must wait a short time before we can move on. */ for (int i = 0; i < 5; i++) { try { tree = repo.getDirectoryContent(".", branch); break; } catch (FileNotFoundException e1) { log.warn("Content in repository not created yet. Retrying connection to fork..."); Thread.sleep(1000); } } for (GHContent con : tree) { modifyOnGithubRecursive(repo, con, branch, img, tag); } }
@NonNull @Override public Iterable<SCMFile> children() throws IOException { checkOpen(); List<GHContent> content = repo.getDirectoryContent(getPath(), ref); List<SCMFile> result = new ArrayList<>(content.size()); for (GHContent c : content) { result.add(new GitHubSCMFile(this, c.getName(), c)); } return result; }
switch (info) { case DIRECTORY_ASSUMED: metadata = repo.getDirectoryContent(getPath(), ref); info = TypeInfo.DIRECTORY_CONFIRMED; resolved = true; break; case DIRECTORY_CONFIRMED: metadata = repo.getDirectoryContent(getPath(), ref); resolved = true; break; if (e.getCause() instanceof IOException && e.getCause().getCause() instanceof JsonMappingException) { metadata = repo.getDirectoryContent(getPath(), ref); info = TypeInfo.DIRECTORY_CONFIRMED; resolved = true;
fileName = path; List<GHContent> directoryContent = repo.getDirectoryContent(dir); for (GHContent content : directoryContent) { if (content.getName().equals(fileName)) {
private void listRepo(final List<String> documents, final GitHubLocation location, final GHRepository repo, final GHBranch branch, final String path) throws IOException { final List<GHContent> content = repo.getDirectoryContent(path, branch.getName()); for (final GHContent c : content) { switch (c.getType()) { case "file": handleFile(documents, location, c); break; case "dir": handleDir(documents, location, repo, branch, c); break; default: log.info("ignoring {}", c.getName()); } } }
protected void modifyOnGithubRecursive(GHRepository repo, GHContent content, String branch, String img, String tag) throws IOException { /* If we have a submodule; we want to skip. Content is submodule when the type is file, but content.getDownloadUrl() is null. */ if (content.isFile() && content.getDownloadUrl() != null) { modifyOnGithub(content, branch, img, tag, ""); } else if(content.isDirectory()) { for (GHContent newContent : repo.getDirectoryContent(content.getPath(), branch)) { modifyOnGithubRecursive(repo, newContent, branch, img, tag); } } else { // The only other case is if we have a file, but content.getDownloadUrl() is null log.info("Skipping submodule {}", content.getName()); } }
protected void modifyOnGithubRecursive(GHRepository repo, GHContent content, String branch, String img, String tag) throws IOException { /* If we have a submodule; we want to skip. Content is submodule when the type is file, but content.getDownloadUrl() is null. */ if (content.isFile() && content.getDownloadUrl() != null) { modifyOnGithub(content, branch, img, tag, ""); } else if(content.isDirectory()) { for (GHContent newContent : repo.getDirectoryContent(content.getPath(), branch)) { modifyOnGithubRecursive(repo, newContent, branch, img, tag); } } else { // The only other case is if we have a file, but content.getDownloadUrl() is null log.info("Skipping submodule {}", content.getName()); } }
@NonNull @Override public SCMProbeStat stat(@NonNull String path) throws IOException { checkOpen(); try { int index = path.lastIndexOf('/') + 1; List<GHContent> directoryContent = repo.getDirectoryContent(path.substring(0, index), ref); for (GHContent content : directoryContent) { if (content.getPath().equals(path)) { if (content.isFile()) { return SCMProbeStat.fromType(SCMFile.Type.REGULAR_FILE); } else if (content.isDirectory()) { return SCMProbeStat.fromType(SCMFile.Type.DIRECTORY); } else if ("symlink".equals(content.getType())) { return SCMProbeStat.fromType(SCMFile.Type.LINK); } else { return SCMProbeStat.fromType(SCMFile.Type.OTHER); } } if (content.getPath().equalsIgnoreCase(path)) { return SCMProbeStat.fromAlternativePath(content.getPath()); } } } catch (FileNotFoundException fnf) { // means that does not exist and this is handled below this try/catch block. } return SCMProbeStat.fromType(SCMFile.Type.NONEXISTENT); }