Search in sources :

Example 1 with CommitCompare

use of com.meisolsson.githubsdk.model.CommitCompare in project PocketHub by pockethub.

the class CommitCompareListFragment method compareCommits.

private void compareCommits() {
    ServiceGenerator.createService(getActivity(), RepositoryCommitService.class).compareCommits(repository.owner().login(), repository.name(), base, head).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).as(AutoDisposeUtils.bindToLifecycle(this)).subscribe(response -> {
        CommitCompare compareCommit = response.body();
        List<GitHubFile> files = compareCommit.files();
        diffStyler.setFiles(files);
        Collections.sort(files, new CommitFileComparator());
        updateList(compareCommit);
    }, error -> ToastUtils.show(getActivity(), R.string.error_commits_load));
}
Also used : GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) CommitCompare(com.meisolsson.githubsdk.model.CommitCompare) RepositoryCommitService(com.meisolsson.githubsdk.service.repositories.RepositoryCommitService)

Example 2 with CommitCompare

use of com.meisolsson.githubsdk.model.CommitCompare in project gh4a by slapperwan.

the class CommitCompareFragment method onCreateDataSingle.

@Override
protected Single<List<Commit>> onCreateDataSingle(boolean bypassCache) {
    RepositoryCommitService service = ServiceFactory.get(RepositoryCommitService.class, bypassCache);
    Single<CommitCompare> compareSingle = service.compareCommits(mRepoOwner, mRepoName, mBase, mHead).map(ApiHelpers::throwOnFailure).onErrorResumeNext(error -> {
        if (error instanceof ApiRequestException) {
            ApiRequestException are = (ApiRequestException) error;
            if (are.getStatus() == HttpURLConnection.HTTP_NOT_FOUND && mBaseLabel != null && mHeadLabel != null) {
                // We got a 404; likely the history of the base branch was rewritten. Try the labels.
                return service.compareCommits(mRepoOwner, mRepoName, mBaseLabel, mHeadLabel).map(ApiHelpers::throwOnFailure);
            }
        }
        return Single.error(error);
    });
    return compareSingle.map(CommitCompare::commits).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, new ArrayList<>()));
}
Also used : ApiRequestException(com.gh4a.ApiRequestException) ArrayList(java.util.ArrayList) ApiHelpers(com.gh4a.utils.ApiHelpers) CommitCompare(com.meisolsson.githubsdk.model.CommitCompare) RepositoryCommitService(com.meisolsson.githubsdk.service.repositories.RepositoryCommitService)

Aggregations

CommitCompare (com.meisolsson.githubsdk.model.CommitCompare)2 RepositoryCommitService (com.meisolsson.githubsdk.service.repositories.RepositoryCommitService)2 ApiRequestException (com.gh4a.ApiRequestException)1 ApiHelpers (com.gh4a.utils.ApiHelpers)1 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)1 ArrayList (java.util.ArrayList)1