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));
}
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<>()));
}
Aggregations