Search in sources :

Example 1 with GHContent

use of org.kohsuke.github.GHContent in project Gargoyle by callakrsos.

the class GitTest method getGargoyleRepository.

@Test
public void getGargoyleRepository() throws IOException {
    GitHub github = GitHub.connect();
    GHUser user = github.getUser("callakrsos");
    Map<String, GHRepository> repositories = user.getRepositories();
    //Repository를 모두 출력
    Iterator<Entry<String, GHRepository>> iterator = repositories.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry<String, GHRepository> next = iterator.next();
        System.out.println(next.getKey() + " - " + next.getValue().getName());
    }
    //Gargoyle Repository 정보 출력
    GHRepository repository = user.getRepository("Gargoyle");
    System.out.println(repository);
    List<GHContent> directoryContent = repository.getDirectoryContent("/");
    //루트 디렉토리 정보 출력
    directoryContent.forEach(con -> {
        System.out.println(String.format("Path : %s\t\t\tsize : %d\t\t\t\tUrl:%s ", con.getPath(), con.getSize(), con.getUrl()));
    });
}
Also used : Entry(java.util.Map.Entry) GHRepository(org.kohsuke.github.GHRepository) GitHub(org.kohsuke.github.GitHub) GHContent(org.kohsuke.github.GHContent) GHUser(org.kohsuke.github.GHUser) Test(org.junit.Test)

Example 2 with GHContent

use of org.kohsuke.github.GHContent in project github-version-statistics by centic9.

the class BaseSearch method processResults.

protected void processResults(GitHub github, Multimap<String, String> versions, Iterable<GHContent> list) throws IOException {
    for (GHContent match : list) {
        final String htmlUrl = match.getHtmlUrl();
        String repo = getNonForkRepository(github, htmlUrl);
        if (repo == null) {
            continue;
        }
        String str = readFileContent(match, htmlUrl, repo);
        if (str == null) {
            continue;
        }
        parseVersion(versions, htmlUrl, repo, str);
    }
}
Also used : GHContent(org.kohsuke.github.GHContent)

Example 3 with GHContent

use of org.kohsuke.github.GHContent in project Gargoyle by callakrsos.

the class GitTest method readContent.

@Test
public void readContent() throws IOException {
    GitHub github = GitHub.connect();
    GHUser user = github.getUser("callakrsos");
    //Gargoyle Repository 정보 출력
    GHRepository repository = user.getRepository("Gargoyle");
    System.out.println(repository);
    GHContent fileContent = repository.getFileContent(".project", "master");
    String string = fileContent.toString();
    System.out.println(string);
    String downloadUrl = fileContent.getDownloadUrl();
    System.out.println(downloadUrl);
    String gitUrl = fileContent.getGitUrl();
    System.out.println(gitUrl);
    try (BufferedReader br = new BufferedReader(new InputStreamReader(fileContent.read()))) {
        String readLine = null;
        while ((readLine = br.readLine()) != null) {
            System.out.println(readLine);
        }
    }
}
Also used : GHRepository(org.kohsuke.github.GHRepository) InputStreamReader(java.io.InputStreamReader) GitHub(org.kohsuke.github.GitHub) GHContent(org.kohsuke.github.GHContent) BufferedReader(java.io.BufferedReader) GHUser(org.kohsuke.github.GHUser) Test(org.junit.Test)

Example 4 with GHContent

use of org.kohsuke.github.GHContent in project nextprot-api by calipho-sib.

the class GitHubServiceImpl method getPage.

@Override
@Cacheable(value = "github-pages")
public String getPage(String folder, String page) {
    String finalPage = page;
    if ("news".equalsIgnoreCase(folder)) {
        finalPage = getCorrespondingPageForNews(page);
    }
    try {
        GitHub github = getGitHubConnection();
        GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
        GHContent content = null;
        String extension = ".md";
        if (folder.contains("json")) {
            // if folder contains json
            extension = ".json";
        }
        content = repo.getFileContent(folder + "/" + finalPage + extension, githubDocBranch);
        return content.getContent();
    } catch (IOException e) {
        e.printStackTrace();
        throw new NextProtException("Documentation not available, sorry for the inconvenience");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) GHRepository(org.kohsuke.github.GHRepository) GitHub(org.kohsuke.github.GitHub) GHContent(org.kohsuke.github.GHContent) IOException(java.io.IOException) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

GHContent (org.kohsuke.github.GHContent)4 GHRepository (org.kohsuke.github.GHRepository)3 GitHub (org.kohsuke.github.GitHub)3 Test (org.junit.Test)2 GHUser (org.kohsuke.github.GHUser)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 Entry (java.util.Map.Entry)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 Cacheable (org.springframework.cache.annotation.Cacheable)1