Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

updates on git tree #56

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
package com.alorma.github.sdk.bean.dto.response;

public class GitTreeEntry extends ShaUrl{
import android.support.annotation.NonNull;

public class GitTreeEntry extends ShaUrl implements Comparable<GitTreeEntry>{

public String path;
public String mode;
public int size;
public GitTreeType type;


@Override
public int compareTo(@NonNull GitTreeEntry another) {
if (another.type == type) {
return path.compareTo(another.path);
} else if (another.type == GitTreeType.tree) {
return 1;
} else {
return another.path.compareTo(path);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.alorma.github.sdk.services.client;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.Log;
import com.alorma.github.sdk.security.GitHub;
import com.alorma.github.sdk.security.InterceptingListOkClient;
import com.alorma.gitskarios.core.ApiClient;
import com.alorma.gitskarios.core.client.BaseListClient;
import com.alorma.gitskarios.core.client.StoreCredentials;
import com.squareup.okhttp.OkHttpClient;

public abstract class GithubListClient<K> extends BaseListClient<K> {

Expand Down Expand Up @@ -36,10 +33,4 @@ public void log(String message) {
public String getAcceptHeader() {
return "application/vnd.github.v3.json";
}

@Nullable
@Override
protected InterceptingListOkClient getInterceptor() {
return new InterceptingListOkClient(new OkHttpClient(), this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class GetGitTreeClient extends GithubClient<GitTree> {

private final RepoInfo info;
private String sha;
private final boolean recursive;

public GetGitTreeClient(Context context, RepoInfo repoInfo, boolean recursive) {
Expand All @@ -18,15 +19,28 @@ public GetGitTreeClient(Context context, RepoInfo repoInfo, boolean recursive) {
this.recursive = recursive;
}

public GetGitTreeClient(Context context, RepoInfo repoInfo, String sha, boolean recursive) {
super(context);
this.info = repoInfo;
this.sha = sha;
this.recursive = recursive;
}

@Override
protected Observable<GitTree> getApiObservable(RestAdapter restAdapter) {
GitDataService gitDataService = restAdapter.create(GitDataService.class);
if (recursive) {
return gitDataService
.repoTreeRecursive(info.owner, info.name, info.branch);
if (sha == null) {
if (recursive) {
return gitDataService.repoTreeRecursive(info.owner, info.name, info.branch);
} else {
return gitDataService.repoTree(info.owner, info.name, info.branch);
}
} else {
return gitDataService
.repoTree(info.owner, info.name, info.branch);
if (recursive) {
return gitDataService.repoTreeRecursive(info.owner, info.name, sha);
} else {
return gitDataService.repoTree(info.owner, info.name, sha);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface GitDataService {
@GET("/repos/{owner}/{repo}/git/refs")
void repoReferences(@Path("owner") String owner, @Path("repo") String name, @Query("page") int page, Callback<List<GitReference>> callback);

//Sync
//Syncx

@GET("/repos/{owner}/{repo}/git/{ref}")
Observable<GitReference> repoReference(@Path("owner") String owner, @Path("repo") String name, @Path(value = "ref", encode = false) String ref);
Expand Down