mirror of
https://github.com/CarmJos/GithubReleases4J.git
synced 2024-09-18 21:25:45 +00:00
修改示例代码
This commit is contained in:
parent
a6ab32a762
commit
3b787b8c0f
@ -18,7 +18,7 @@ public class GithubReleasesTest {
|
||||
@Test
|
||||
public void onTest() {
|
||||
|
||||
GithubReleases4J.listReleases("CarmJos", "EasyPlugin")
|
||||
GithubReleases4J.listReleases("CarmJos", "GithubReleases4J")
|
||||
.stream().limit(2).forEach(GithubReleasesTest::printInfo);
|
||||
|
||||
GithubRelease release = GithubReleases4J.getLatestRelease("CarmJos", "UltraDepository");
|
||||
@ -32,16 +32,18 @@ public class GithubReleasesTest {
|
||||
private static void printInfo(@Nullable GithubRelease release) {
|
||||
if (release == null) System.out.println("# NULL");
|
||||
else {
|
||||
System.out.println("# " + release.getName() + " [" + FORMAT.format(release.getCreateTime()) + "]");
|
||||
print("# %s %s [%s] ",
|
||||
release.getRepository(), release.getName(),
|
||||
FORMAT.format(release.getCreateTime())
|
||||
);
|
||||
List<GithubAsset> assets = release.getAssets();
|
||||
assets.forEach(GithubReleasesTest::printAssets);
|
||||
}
|
||||
}
|
||||
|
||||
private static void printAssets(@Nullable GithubAsset assets) {
|
||||
if (assets == null) System.out.println("- NULL");
|
||||
else {
|
||||
System.out.println("- " + assets.getName() + " [" + assets.getSize() + "]");
|
||||
if (assets != null) {
|
||||
print("- %s (%s B)", assets.getName(), assets.getSize());
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,12 +51,16 @@ public class GithubReleasesTest {
|
||||
if (!DOWNLOAD) return;
|
||||
if (assets == null) return;
|
||||
try {
|
||||
File file = assets.download();
|
||||
System.out.println("- at " + file.getAbsolutePath());
|
||||
File file = assets.download(StandardCopyOption.REPLACE_EXISTING);
|
||||
System.out.println("| -> " + file.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void print(String format, Object... params) {
|
||||
System.out.printf((format) + "%n", params);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
public class GithubUserTestTest {
|
||||
public class GithubUserInfoTest {
|
||||
|
||||
public static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
@ -1,7 +1,7 @@
|
||||
import cc.carm.lib.githubreleases4j.GithubReleases4J;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GithubVersionTest {
|
||||
public class GithubVersionCheckerTest {
|
||||
|
||||
|
||||
@Test
|
Loading…
Reference in New Issue
Block a user