public void safeDeleteRepo(GHRepository repo) throws IOException { try { repo.delete(); } catch (IOException e) { throw new IOException("Please verify that the GitHub token " + "provided has access to deleting repositories."); } }
public void safeDeleteRepo(GHRepository repo) throws IOException { try { repo.delete(); } catch (IOException e) { throw new IOException("Please verify that the GitHub token " + "provided has access to deleting repositories."); } }
@PreDestroy public void delete() { try { ghRepo.delete(); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } submodules.forEach(TestGitHubRepository::delete); LOG.info("GitHub repo {} has been removed", ghRepo.getHtmlUrl()); }
private static Exception checkAndDelete(GHRepository repo) { log.info("deleting {}", repo.getFullName()); try { repo.delete(); } catch (Exception e) { return e; } return null; }
public static void checkAndDeleteBefore(String repoName, GitHub github) throws IOException, InterruptedException { GHRepository repo; try { repo = github.getRepository(repoName); } catch (FileNotFoundException fileNotFoundException) { return; } repo.delete(); // Make sure the repo is actually deleted for (int attempts = 0; attempts < 60; attempts++) { try { github.getRepository(repoName); } catch (FileNotFoundException fileNotFoundException) { return; } log.info("Waiting for {} to fully delete...", repoName); Thread.sleep(TimeUnit.SECONDS.toMillis(1)); } throw new FileNotFoundException(String.format("Unable to pre-delete repository %s during pre-test cleanup", repoName)); }
public static void deleteAllRepos(String repoPrefix, String gitHubUsername, String gitHubPassword) throws IOException { GitHub gitHub = GitHub.connectUsingPassword(gitHubUsername, gitHubPassword); gitHub .getMyself() .getAllRepositories() .keySet() .stream() .filter(repoName -> repoName.startsWith(repoPrefix)) .forEach( repoName -> { String repoAddress = gitHubUsername + "/" + repoName; LOG.info("Removing repo " + repoAddress + "..."); try { gitHub.getRepository(repoAddress).delete(); } catch (IOException e) { e.printStackTrace(); } }); }