use of org.kohsuke.github.GHRepository in project Gargoyle by callakrsos.
the class GitTest method readContent.
@Test
public void readContent() throws IOException {
GitHub github = GitHub.connect();
GHUser user = github.getUser("callakrsos");
//Gargoyle Repository 정보 출력
GHRepository repository = user.getRepository("Gargoyle");
System.out.println(repository);
GHContent fileContent = repository.getFileContent(".project", "master");
String string = fileContent.toString();
System.out.println(string);
String downloadUrl = fileContent.getDownloadUrl();
System.out.println(downloadUrl);
String gitUrl = fileContent.getGitUrl();
System.out.println(gitUrl);
try (BufferedReader br = new BufferedReader(new InputStreamReader(fileContent.read()))) {
String readLine = null;
while ((readLine = br.readLine()) != null) {
System.out.println(readLine);
}
}
}
use of org.kohsuke.github.GHRepository in project Gargoyle by callakrsos.
the class GitTest method listRepositories.
@Test
public void listRepositories() throws IOException {
GitHub github = GitHub.connect();
PagedIterable<GHRepository> listAllPublicRepositories = github.listAllPublicRepositories();
PagedIterator<GHRepository> iterator = listAllPublicRepositories.iterator();
while (iterator.hasNext()) {
GHRepository next = iterator.next();
System.out.println(next);
}
}
use of org.kohsuke.github.GHRepository in project blueocean-plugin by jenkinsci.
the class GithubEditorTest method deleteRepository.
/**
* Cleans up repository after the test has completed.
*
* @throws IOException
*/
@After
public void deleteRepository() throws IOException {
if (deleteRepo) {
try {
GHRepository repositoryToDelete = github.getRepository(organization + "/" + repo);
repositoryToDelete.delete();
logger.info("Deleted repository " + repo);
} catch (FileNotFoundException e) {
}
}
}
use of org.kohsuke.github.GHRepository in project blueocean-plugin by jenkinsci.
the class GithubHelper method createEmptyRepository.
public String createEmptyRepository() throws IOException {
GitHub github = getGitHub();
String repositoryName = !useRandomSuffix ? this.repositoryName : this.repositoryName + "-" + getRandomSuffix();
try {
String repositoryFullname = organizationOrUsername + "/" + repositoryName;
GHRepository repositoryToDelete = github.getRepository(repositoryFullname);
repositoryToDelete.delete();
logger.info("Deleted repository " + repositoryFullname);
} catch (FileNotFoundException e) {
// fine to ignore error if the repo doesn't exist
}
GHCreateRepositoryBuilder builder;
if (organizationOrUsername.equals(github.getMyself().getLogin())) {
builder = github.createRepository(repositoryName);
} else {
try {
builder = github.getOrganization(organizationOrUsername).createRepository(repositoryName);
} catch (FileNotFoundException e) {
logger.error("found not find organization " + organizationOrUsername);
throw e;
}
}
githubRepository = builder.autoInit(true).create();
logger.info("Created repository " + githubRepository.getFullName());
return repositoryName;
}
use of org.kohsuke.github.GHRepository in project Robot by fo0.
the class UpdateUtils method doUpdate.
public static void doUpdate() {
try {
GitHub gitHub = GitHub.connectAnonymously();
GHRepository repository = gitHub.getRepository(CONSTANTS.GITHUB_URI);
GHRelease latest = repository.getLatestRelease();
boolean newerVersionAvailable = new Semver(latest.getTagName().replaceAll("v", "")).isGreaterThan(new Semver(CONSTANTS.VERSION));
if (!newerVersionAvailable) {
Logger.info("no newer version available, skipping now");
Logger.info("current version: " + CONSTANTS.VERSION);
Logger.info("latest version: " + latest.getTagName().replaceAll("v", ""));
return;
} else {
Logger.info("detected new version");
Logger.info("current version: " + CONSTANTS.VERSION);
Logger.info("latest version: " + latest.getTagName().replaceAll("v", ""));
}
GHAsset asset = latest.getAssets().get(0);
Logger.info("downloading file from github: " + asset.getBrowserDownloadUrl());
File latestFile = File.createTempFile(Random.alphanumeric(10), ".patch");
latestFile.deleteOnExit();
FileUtils.copyToFile(new URL(asset.getBrowserDownloadUrl()).openStream(), latestFile);
Logger.info("download finished");
Logger.info("applying patch...");
File currentPath = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath());
Utils.writeBytesToFile(IOUtils.toByteArray(new FileInputStream(latestFile)), currentPath);
// FileUtils.moveFile(latestFile, currentPath);
try {
latestFile.delete();
} catch (Exception e) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations