Search in sources :

Example 1 with RepositoryId

use of org.eclipse.egit.github.core.RepositoryId in project Bitocle by mthli.

the class CommitTask method doInBackground.

@Override
protected Boolean doInBackground(Void... params) {
    if (flag == Flag.REPO_COMMIT_FIRST || flag == Flag.REPO_COMMIT_REFRESH) {
        RepositoryId id = RepositoryId.create(repoItem.getOwner(), repoItem.getName());
        PageIterator<RepositoryCommit> pageIterator = commitService.pageCommits(id, 17);
        iterator = pageIterator.next().iterator();
    } else {
        RepositoryId id = RepositoryId.create(starItem.getOwner(), starItem.getName());
        PageIterator<RepositoryCommit> pageIterator = commitService.pageCommits(id, 17);
        iterator = pageIterator.next().iterator();
    }
    if (isCancelled()) {
        return false;
    }
    return true;
}
Also used : RepositoryId(org.eclipse.egit.github.core.RepositoryId) RepositoryCommit(org.eclipse.egit.github.core.RepositoryCommit)

Example 2 with RepositoryId

use of org.eclipse.egit.github.core.RepositoryId in project Bitocle by mthli.

the class RepoContentTask method doInBackground.

@Override
protected Boolean doInBackground(Void... params) {
    if (flag == Flag.REPO_CONTENT_FIRST || flag == Flag.REPO_CONTENT_REFRESH) {
        String master = "heads/master";
        RepositoryId id = RepositoryId.create(owner, name);
        Reference ref;
        String sha;
        if (!fragment.isToggle()) {
            try {
                ref = dataService.getReference(id, master);
            } catch (IOException i) {
                return false;
            }
            sha = ref.getObject().getSha();
            if (isCancelled()) {
                return false;
            }
        } else {
            sha = fragment.getBookmarkItem().getSha();
        }
        try {
            root = dataService.getTree(id, sha, true);
        } catch (IOException i) {
            return false;
        }
    }
    if (isCancelled()) {
        return false;
    }
    return true;
}
Also used : Reference(org.eclipse.egit.github.core.Reference) IOException(java.io.IOException) RepositoryId(org.eclipse.egit.github.core.RepositoryId)

Example 3 with RepositoryId

use of org.eclipse.egit.github.core.RepositoryId in project Bitocle by mthli.

the class StarContentTask method doInBackground.

@Override
protected Boolean doInBackground(Void... params) {
    if (flag == Flag.STAR_CONTENT_FIRST || flag == Flag.STAR_CONTENT_REFRESH) {
        String master = "heads/master";
        RepositoryId id = RepositoryId.create(owner, name);
        Reference ref;
        String sha;
        if (!fragment.isToggle()) {
            try {
                ref = dataService.getReference(id, master);
            } catch (IOException i) {
                return false;
            }
            sha = ref.getObject().getSha();
            if (isCancelled()) {
                return false;
            }
        } else {
            sha = fragment.getBookmarkItem().getSha();
        }
        try {
            root = dataService.getTree(id, sha, true);
        } catch (IOException i) {
            return false;
        }
    }
    if (isCancelled()) {
        return false;
    }
    return true;
}
Also used : Reference(org.eclipse.egit.github.core.Reference) IOException(java.io.IOException) RepositoryId(org.eclipse.egit.github.core.RepositoryId)

Example 4 with RepositoryId

use of org.eclipse.egit.github.core.RepositoryId in project Bitocle by mthli.

the class WebViewTask method doInBackground.

@Override
protected Boolean doInBackground(Void... params) {
    GitHubClient client = fragment.getClient();
    RepositoryId id = RepositoryId.create(owner, name);
    DataService dataService = new DataService(client);
    MarkdownService markdownService = new MarkdownService(client);
    Blob blob;
    try {
        blob = dataService.getBlob(id, sha);
    } catch (IOException i) {
        return false;
    }
    if (isCancelled()) {
        return false;
    }
    String base64 = blob.getContent();
    if (!MimeType.isImage(filename)) {
        byte[] bytes = EncodingUtils.fromBase64(base64);
        content = new String(bytes);
    }
    if (MimeType.isImage(filename)) {
        String imageUrl = GetImage.getImageUrl(base64, MimeType.getImageExtension(filename));
        image = GetImage.getImage(imageUrl);
    } else if (MimeType.isMarkdown(filename)) {
        try {
            content = markdownService.getHtml(content, MarkdownService.MODE_GFM);
            content = StyleMarkdown.styleMarkdown(content);
        } catch (IOException i) {
            return false;
        }
    } else {
        content = SyntaxCode.syntaxCode(content, css);
    }
    if (isCancelled()) {
        return false;
    }
    return true;
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) Blob(org.eclipse.egit.github.core.Blob) MarkdownService(org.eclipse.egit.github.core.service.MarkdownService) IOException(java.io.IOException) RepositoryId(org.eclipse.egit.github.core.RepositoryId) DataService(org.eclipse.egit.github.core.service.DataService)

Aggregations

RepositoryId (org.eclipse.egit.github.core.RepositoryId)4 IOException (java.io.IOException)3 Reference (org.eclipse.egit.github.core.Reference)2 Blob (org.eclipse.egit.github.core.Blob)1 RepositoryCommit (org.eclipse.egit.github.core.RepositoryCommit)1 GitHubClient (org.eclipse.egit.github.core.client.GitHubClient)1 DataService (org.eclipse.egit.github.core.service.DataService)1 MarkdownService (org.eclipse.egit.github.core.service.MarkdownService)1