/** * List immediate children of this directory. */ public PagedIterable<GHContent> listDirectoryContent() throws IOException { if (!isDirectory()) throw new IllegalStateException(path+" is not a directory"); return new PagedIterable<GHContent>() { public PagedIterator<GHContent> iterator() { return new PagedIterator<GHContent>(root.retrieve().asIterator(url, GHContent[].class)) { @Override protected void wrapUp(GHContent[] page) { GHContent.wrap(page, repository); } }; } }; }
/** * List immediate children of this directory. */ public PagedIterable<GHContent> listDirectoryContent() throws IOException { if (!isDirectory()) throw new IllegalStateException(path+" is not a directory"); return new PagedIterable<GHContent>() { public PagedIterator<GHContent> _iterator(int pageSize) { return new PagedIterator<GHContent>(root.retrieve().asIterator(url, GHContent[].class, pageSize)) { @Override protected void wrapUp(GHContent[] page) { GHContent.wrap(page, repository); } }; } }; }
/** * List immediate children of this directory. */ public PagedIterable<GHContent> listDirectoryContent() throws IOException { if (!isDirectory()) throw new IllegalStateException(path+" is not a directory"); return new PagedIterable<GHContent>() { public PagedIterator<GHContent> _iterator(int pageSize) { return new PagedIterator<GHContent>(root.retrieve().asIterator(url, GHContent[].class, pageSize)) { @Override protected void wrapUp(GHContent[] page) { GHContent.wrap(page, repository); } }; } }; }
private GitHubSCMFile(@NonNull GitHubSCMFile parent, String name, GHContent metadata) { super(parent, name); this.closable = parent.closable; this.repo = parent.repo; this.ref = parent.ref; if (metadata.isDirectory()) { info = TypeInfo.DIRECTORY_CONFIRMED; // we have not listed the children yet, but we know it is a directory } else { info = TypeInfo.NON_DIRECTORY_CONFIRMED; this.metadata = metadata; resolved = true; } }
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); }