From 5a7dec871f26eae3295d29e0c48f19e1f4e517d7 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Wed, 29 Jun 2022 16:18:37 +0200 Subject: [PATCH 1/5] Add custom APIs to get files This is necessary to replace web interface calls with API calls and to support LFS files. --- .../tea4j/v2/apis/custom/CustomApi.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java index ac4e4f4..c2b88fc 100644 --- a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java +++ b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java @@ -98,4 +98,37 @@ public interface CustomApi { @Headers({"Content-Type:application/json"}) @HTTP(method = "DELETE", path = "user/emails", hasBody = true) Call userDeleteEmailWithBody(@Body DeleteEmailOption body); + + /** + * Get a file from a repository + * + * @param owner owner of the repo (required) + * @param repo name of the repo (required) + * @param filepath filepath of the file to get (required) + * @param ref The name of the commit/branch/tag. Default the repository’s default branch (usually + * master) (optional) + * @return Call<Void> + */ + @GET("repos/{owner}/{repo}/raw/{filepath}") + Call repoGetRawFile( + @retrofit2.http.Path("owner") String owner, + @retrofit2.http.Path("repo") String repo, + @retrofit2.http.Path("filepath") String filepath, + @retrofit2.http.Query("ref") String ref); + /** + * Get a file or it's LFS object from a repository + * + * @param owner owner of the repo (required) + * @param repo name of the repo (required) + * @param filepath filepath of the file to get (required) + * @param ref The name of the commit/branch/tag. Default the repository’s default branch (usually + * master) (optional) + * @return Call<Void> + */ + @GET("repos/{owner}/{repo}/media/{filepath}") + Call repoGetRawFileOrLFS( + @retrofit2.http.Path("owner") String owner, + @retrofit2.http.Path("repo") String repo, + @retrofit2.http.Path("filepath") String filepath, + @retrofit2.http.Query("ref") String ref); } From 22065543949d76019a00d6f483d370ad5bd29efc Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Wed, 29 Jun 2022 16:54:13 +0200 Subject: [PATCH 2/5] Rm newline --- .../src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java | 1 + 1 file changed, 1 insertion(+) diff --git a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java index c2b88fc..79d8c94 100644 --- a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java +++ b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java @@ -115,6 +115,7 @@ public interface CustomApi { @retrofit2.http.Path("repo") String repo, @retrofit2.http.Path("filepath") String filepath, @retrofit2.http.Query("ref") String ref); + /** * Get a file or it's LFS object from a repository * From 168c8890bfba64539d103b564270fc76f217d656 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Wed, 20 Jul 2022 14:23:34 +0200 Subject: [PATCH 3/5] Fix enconding --- .../org/gitnex/tea4j/v2/apis/custom/CustomApi.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java index 79d8c94..0f6b980 100644 --- a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java +++ b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java @@ -22,7 +22,7 @@ public interface CustomApi { * @param repo name of the repo (required) * @param id id of the comment to edit (required) * @param body (optional) - * @return Call<Void> + * @return Call; */ @Headers({"Content-Type:application/json"}) @HTTP( @@ -42,7 +42,7 @@ public interface CustomApi { * @param repo name of the repo (required) * @param index index of the issue (required) * @param body (optional) - * @return Call<Void> + * @return Call; */ @Headers({"Content-Type:application/json"}) @HTTP(method = "DELETE", path = "repos/{owner}/{repo}/issues/{index}/reactions", hasBody = true) @@ -59,7 +59,7 @@ public interface CustomApi { * @param repo name of the repo (required) * @param filepath path of the file to delete (required) * @param body (required) - * @return Call<FileDeleteResponse> + * @return Call; */ @Headers({"Content-Type:application/json"}) @HTTP(method = "DELETE", path = "repos/{owner}/{repo}/contents/{filepath}", hasBody = true) @@ -76,7 +76,7 @@ public interface CustomApi { * @param repo name of the repo (required) * @param index index of the pull request (required) * @param body (required) - * @return Call<Void> + * @return Call; */ @Headers({"Content-Type:application/json"}) @HTTP( @@ -93,7 +93,7 @@ public interface CustomApi { * Delete email addresses * * @param body (optional) - * @return Call<Void> + * @return Call; */ @Headers({"Content-Type:application/json"}) @HTTP(method = "DELETE", path = "user/emails", hasBody = true) @@ -107,7 +107,7 @@ public interface CustomApi { * @param filepath filepath of the file to get (required) * @param ref The name of the commit/branch/tag. Default the repository’s default branch (usually * master) (optional) - * @return Call<Void> + * @return Call; */ @GET("repos/{owner}/{repo}/raw/{filepath}") Call repoGetRawFile( @@ -124,7 +124,7 @@ public interface CustomApi { * @param filepath filepath of the file to get (required) * @param ref The name of the commit/branch/tag. Default the repository’s default branch (usually * master) (optional) - * @return Call<Void> + * @return Call; */ @GET("repos/{owner}/{repo}/media/{filepath}") Call repoGetRawFileOrLFS( From 7a5d59ec64c9969a2b16594870ecd480e8c8bfe2 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Wed, 20 Jul 2022 14:28:03 +0200 Subject: [PATCH 4/5] Fix import --- .../main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java index 0f6b980..5495e13 100644 --- a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java +++ b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java @@ -1,6 +1,7 @@ package org.gitnex.tea4j.v2.apis.custom; import org.gitnex.tea4j.v2.models.*; +import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.*; @@ -107,7 +108,7 @@ public interface CustomApi { * @param filepath filepath of the file to get (required) * @param ref The name of the commit/branch/tag. Default the repository’s default branch (usually * master) (optional) - * @return Call; + * @return Call; */ @GET("repos/{owner}/{repo}/raw/{filepath}") Call repoGetRawFile( @@ -124,7 +125,7 @@ public interface CustomApi { * @param filepath filepath of the file to get (required) * @param ref The name of the commit/branch/tag. Default the repository’s default branch (usually * master) (optional) - * @return Call; + * @return Call; */ @GET("repos/{owner}/{repo}/media/{filepath}") Call repoGetRawFileOrLFS( From a4c0f023906a35dfe65afaf01885bd2820f49dbe Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Wed, 20 Jul 2022 16:24:36 +0200 Subject: [PATCH 5/5] Fix encoding --- .../main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java index 5495e13..1935fc5 100644 --- a/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java +++ b/custom/src/main/java/org/gitnex/tea4j/v2/apis/custom/CustomApi.java @@ -118,7 +118,7 @@ public interface CustomApi { @retrofit2.http.Query("ref") String ref); /** - * Get a file or it's LFS object from a repository + * Get a file or it's LFS object from a repository * * @param owner owner of the repo (required) * @param repo name of the repo (required)