public GitHubber(String accessToken) { this.accessToken = accessToken; gitHubClient = new GitHubClient(); gitHubClient.setOAuth2Token(accessToken); repositoryService = new RepositoryService(gitHubClient); }
/** * Get repositories for the currently authenticated user * * @return list of repositories * @throws IOException */ public List<Repository> getRepositories() throws IOException { return getRepositories((Map<String, String>) null); }
public Repository getRepository(final String username, final String reponame) { Repository repository = null; try { repository = service.getRepository(username, reponame); } catch (IOException e) { log.error("IO exception fetchin Repository {}/{}", new Object[]{username, reponame, e}); } catch (NullPointerException npe) { log.error("NullPointerException fetching repository {}/{}", new Object[]{username, reponame, npe}); } return repository; }
/** * @inheritDoc */ @Override public PullRequest getPullRequestIfExists(String base, String head, String repository) { RepositoryService repositoryService = new RepositoryService(); org.eclipse.egit.github.core.Repository openmrs = null; boolean exists = false; try { openmrs = repositoryService.getRepository(OPENMRS_USER, repository); PullRequestService pullRequestService = new PullRequestService(); List<PullRequest> openPRs = pullRequestService.getPullRequests(openmrs, "open"); for(PullRequest openPR : openPRs){ if(matchPullRequest(base, head, openPR)){ return openPR; } } } catch (IOException e) { throw new RuntimeException("Failed to access remote repository data",e); } return null; }
@WorkerThread public List<Repository> getRepositories() throws IOException { org.eclipse.egit.github.core.service.RepositoryService service = new org.eclipse.egit.github.core.service.RepositoryService(); service.getClient().setOAuth2Token(getAccessToken().getToken()); return service.getRepositories(); } }
RepositoryService repoService = new RepositoryService(client); List<Repository> repositories = null; if (org.equals(userLogin)) { filters.put("affiliation", "owner"); filters.put("visibility", "all"); repositories = repoService.getRepositories(filters); } else { repositories = repoService.getOrgRepositories(org);
@Override public List<String> getRepositories() { // Logging logger.debug("[github] Getting repository list"); // Getting a client GitHubClient client = createGitHubClient(); // Service RepositoryService repositoryService = new RepositoryService(client); // Gets the repository names try { return repositoryService.getRepositories().stream() .map(Repository::getName) .collect(Collectors.toList()); } catch (IOException e) { throw new OntrackGitHubClientException(e); } }
/** * @see io.apicurio.hub.api.github.IGitHubSourceConnector#getBranches(java.lang.String, java.lang.String) */ @Override public Collection<SourceCodeBranch> getBranches(String org, String repo) throws GitHubException, SourceConnectorException { logger.debug("Getting the branches from {} / {}", org, repo); Collection<SourceCodeBranch> rval = new HashSet<>(); try { GitHubClient client = githubClient(); RepositoryService repoService = new RepositoryService(client); Repository repository = repoService.getRepository(org, repo); List<RepositoryBranch> branches = repoService.getBranches(repository); for (RepositoryBranch branch : branches) { SourceCodeBranch ghBranch = new SourceCodeBranch(); ghBranch.setName(branch.getName()); ghBranch.setCommitId(branch.getCommit().getSha()); rval.add(ghBranch); } } catch (IOException e) { logger.error("Error getting GitHub branches.", e); throw new GitHubException("Error getting GitHub branches.", e); } return rval; }
/** * @inheritDoc */ @Override public PullRequest openPullRequest(GithubPrRequest request) { RepositoryService repositoryService = new RepositoryService(); repositoryService.getClient().setCredentials(request.getUsername(), request.getPassword()); org.eclipse.egit.github.core.Repository openmrs = null; try { openmrs = repositoryService.getRepository(OPENMRS_USER, request.getRepository()); } catch (IOException e) { throw new RuntimeException("Failed to get repository data", e); } PullRequestService pullRequestService = new PullRequestService(); pullRequestService.getClient().setCredentials(request.getUsername(), request.getPassword()); PullRequest pr = new org.eclipse.egit.github.core.PullRequest(); pr.setTitle(request.getTitle()); pr.setHead(new PullRequestMarker().setLabel(request.getHead())); pr.setBase(new PullRequestMarker().setLabel(request.getBase())); pr.setBody(request.getDescription()); try { return pullRequestService.createPullRequest(openmrs, pr); } catch (IOException e) { throw new RuntimeException("Failed to create pull request:"+pr, e); } }
private void forkRepo(String repoName, String repoOwner) { wizard.showMessage("Forking " + repoName + " from " + repoOwner); GitHubClient client = new GitHubClient(); client.setCredentials(githubUsername, githubPassword); RepositoryService service = new RepositoryService(); service.getClient().setCredentials(githubUsername, githubPassword); RepositoryId toBeForked = new RepositoryId(repoOwner, repoName); try { service.forkRepository(toBeForked); } catch (IOException e) { throw new IllegalStateException("Failed to fork repository", e); } }
when(repositoryService.forkRepository(any(RepositoryId.class), anyString())).thenReturn(forkedRepository); when(repositoryService.getRepositories(anyString())).thenReturn(testRepoList);
/** * Fork given repository into new repository under the currently * authenticated user. * * @param repository * @return forked repository * @throws IOException */ public Repository forkRepository(IRepositoryIdProvider repository) throws IOException { return forkRepository(repository, null); }
/** * Get organization repositories for the given organization * * @param organization * @return list of repositories * @throws IOException */ public List<Repository> getOrgRepositories(String organization) throws IOException { return getOrgRepositories(organization, null); }
public AbstractGitHubConsumer(GitHubEndpoint endpoint, Processor processor) throws Exception { super(endpoint, processor); this.endpoint = endpoint; Registry registry = endpoint.getCamelContext().getRegistry(); Object service = registry.lookupByName(GitHubConstants.GITHUB_REPOSITORY_SERVICE); if (service != null) { LOG.debug("Using RepositoryService found in registry {}", service.getClass().getCanonicalName()); repositoryService = (RepositoryService) service; } else { repositoryService = new RepositoryService(); } initService(repositoryService); repository = repositoryService.getRepository(endpoint.getRepoOwner(), endpoint.getRepoName()); }
public void executeWorkItem(WorkItem workItem, WorkItemManager workItemManager) { try { RequiredParameterValidator.validate(this.getClass(), workItem); Map<String, Object> results = new HashMap<String, Object>(); String repoOwner = (String) workItem.getParameter("RepoOwner"); String repoName = (String) workItem.getParameter("RepoName"); String organization = (String) workItem.getParameter("Organization"); Repository forkedRepository; RepositoryService repoService = auth.getRespositoryService(this.userName, this.password); RepositoryId toBeForkedRepo = new RepositoryId(repoOwner, repoName); if (StringUtils.isNotEmpty(organization)) { forkedRepository = repoService.forkRepository(toBeForkedRepo, organization); } else { forkedRepository = repoService.forkRepository(toBeForkedRepo); } results.put(RESULTS_VALUE, new RepositoryInfo(forkedRepository)); workItemManager.completeWorkItem(workItem.getId(), results); } catch (Exception e) { handleException(e); } }
public AbstractGitHubProducer(GitHubEndpoint endpoint) throws Exception { super(endpoint); this.endpoint = endpoint; Registry registry = endpoint.getCamelContext().getRegistry(); Object service = registry.lookupByName(GitHubConstants.GITHUB_REPOSITORY_SERVICE); if (service != null) { repositoryService = (RepositoryService) service; } else { repositoryService = new RepositoryService(); } initService(repositoryService); repository = repositoryService.getRepository(endpoint.getRepoOwner(), endpoint.getRepoName()); }
public RepositoryMinerV3(final IGitHubClient ghc) { super(); service = new RepositoryService(ghc); }
public List<Repository> getRepositories(final String login) { List<Repository> repos = null; try { repos = service.getRepositories(login); } catch (IOException e) { log.error("IOException in getRepositories: {}", login, e); } catch (NullPointerException npe) { log.error("NullPointerException in getRepositories: {}", login, npe); } return repos; }
/** * Get repository * * @param owner * @param name * @return repository * @throws IOException */ public Repository getRepository(final String owner, final String name) throws IOException { return getRepository(RepositoryId.create(owner, name)); }
public RepositoryService getRespositoryService(String username, String password) throws IOException { return new RepositoryService(getGitHubClient(username, password)); }