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); } }
@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(); } }
/** * @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); } }