/** * Create repository id from given owner and name. * * @param owner * @param name * @return repository id */ public static RepositoryId create(String owner, String name) { return new RepositoryId(owner, name); }
/** * Create repository from id. The id is split on the '/' character and the * first two non-empty segments are interpreted to be the repository owner * and name. * * @param id * @return repository */ public static RepositoryId createFromId(String id) { if (id == null || id.length() == 0) return null; String owner = null; String name = null; for (String segment : id.split("/")) //$NON-NLS-1$ if (segment.length() > 0) if (owner == null) owner = segment; else if (name == null) name = segment; else break; return owner != null && owner.length() > 0 && name != null && name.length() > 0 ? new RepositoryId(owner, name) : null; }
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); } }
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); } }
this.password); RepositoryId repositoryId = new RepositoryId(repoOwner, repoName); if (pullRequestService.getPullRequest(repositoryId,
public GitHubCommentsProvider( ViolationsLogger violationsLogger, final ViolationCommentsToGitHubApi violationCommentsToGitHubApi) { this.violationsLogger = violationsLogger; final GitHubClient gitHubClient = createClient(violationCommentsToGitHubApi.getGitHubUrl()); if (violationCommentsToGitHubApi.getOAuth2Token() != null) { gitHubClient.setOAuth2Token(violationCommentsToGitHubApi.getOAuth2Token()); } else if (violationCommentsToGitHubApi.getUsername() != null && violationCommentsToGitHubApi.getPassword() != null) { gitHubClient.setCredentials( violationCommentsToGitHubApi.getUsername(), violationCommentsToGitHubApi.getPassword()); } repository = new RepositoryId( violationCommentsToGitHubApi.getRepositoryOwner(), violationCommentsToGitHubApi.getRepositoryName()); pullRequestService = new PullRequestService(gitHubClient); issueSerivce = new IssueService(gitHubClient); List<RepositoryCommit> commits = null; try { commits = pullRequestService.getCommits( repository, violationCommentsToGitHubApi.getPullRequestId()); } catch (final IOException e) { throw new RuntimeException(e); } pullRequestCommit = commits.get(commits.size() - 1).getSha(); this.violationCommentsToGitHubApi = violationCommentsToGitHubApi; }
GitHubClient client = new GitHubClient(); client.setOAuth2Token(gitAccessToken); RepositoryId repoID = new RepositoryId(gitRepoUser, gitRepo); IssueService issueService = new IssueService(client);