From e9c50380100959fe4a0bf1c34c018b43e16540df Mon Sep 17 00:00:00 2001 From: JFronny <33260128+jfronny@users.noreply.github.com> Date: Tue, 11 May 2021 13:19:29 +0200 Subject: [PATCH] Do the same thing for getFromTag --- .../resclone/fetchers/GitHubFetcher.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/gitlab/jfronny/resclone/fetchers/GitHubFetcher.java b/src/main/java/io/gitlab/jfronny/resclone/fetchers/GitHubFetcher.java index 48308cf..8b31a0f 100644 --- a/src/main/java/io/gitlab/jfronny/resclone/fetchers/GitHubFetcher.java +++ b/src/main/java/io/gitlab/jfronny/resclone/fetchers/GitHubFetcher.java @@ -9,7 +9,6 @@ import org.jetbrains.annotations.Nullable; import java.io.IOException; public class GitHubFetcher extends PackFetcher { - @Override public String getSourceTypeName() { return "github"; @@ -23,12 +22,12 @@ public class GitHubFetcher extends PackFetcher { throw new Exception("Minimum source must contain \"user/repo\"."); } - /* "user/repo" - Gets from latest commit of main/master branch. */ + //"user/repo" - Gets from latest commit of main/master branch. else if (parts.length == 2) { - return getFromBranch(parts[0] + "/" + parts[1], null); + return getFromBranch(baseUrl, null); } - /* "user/repo/branch/branchName" - Gets from latest commit of specified branch. */ + //"user/repo/branch/branchName" - Gets from latest commit of specified branch. else if (parts[2].equalsIgnoreCase("branch")) { if (parts.length < 4) throw new Exception("Missing branch name in source definition."); else { @@ -37,7 +36,7 @@ public class GitHubFetcher extends PackFetcher { } } - /* "user/repo/release" - Gets from the latest release. */ + //"user/repo/release" - Gets from the latest release. else if (parts[2].equalsIgnoreCase("release")) { try { JsonObject latestRelease = UrlUtils.readJsonFromURL("https://api.github.com/repos/" + parts[0] + "/" + parts[1] + "/releases/latest", JsonObject.class); @@ -61,11 +60,11 @@ public class GitHubFetcher extends PackFetcher { } } - /* "user/repo/tag/tagNum" - Gets from a specified tag. */ + //"user/repo/tag/tagNum" - Gets from a specified tag. else if (parts[2].equalsIgnoreCase("tag")) { if (parts.length < 4) throw new Exception("Missing tag number in source definition."); else { - return getFromTag(parts[0], parts[1], parts[3]); + return getFromTag(parts[0] + "/" + parts[1], parts[3]); } } @@ -85,9 +84,8 @@ public class GitHubFetcher extends PackFetcher { return "https://codeload.github.com/" + repo + "/legacy.zip/refs/heads/" + branch; } - private String getFromTag(String user, String repo, String tag) { + private String getFromTag(String repo, String tag) { Resclone.LOGGER.info("Getting from tag " + tag + "."); - return "https://codeload.github.com/" + user + "/" + repo + "/legacy.zip/refs/tags/" + tag; + return "https://codeload.github.com/" + repo + "/legacy.zip/refs/tags/" + tag; } - } \ No newline at end of file