use of org.eclipse.egit.github.core.PullRequestMarker in project pivotal-cla by pivotalsoftware.
the class SmokeTests method createPullRequest.
/**
* @return the HTML link of the Pull Request
* @throws InterruptedException
*/
private static String createPullRequest(User user, int count) throws IOException, InterruptedException {
GitHubClient client = createClient(user.getGitHubAccessToken());
PullRequestService pulls = new PullRequestService(client);
RestTemplate rest = new RestTemplate();
// get sha for master
DataService references = new DataService(client);
RepositoryId forkRepositoryId = RepositoryId.create(user.getGitHubUsername(), "cla-test");
Reference forked = references.getReference(forkRepositoryId, "heads/master");
// create a branch for our Pull Request
Reference createPullRequestBranch = new Reference();
createPullRequestBranch.setRef("refs/heads/pull-" + count);
createPullRequestBranch.setObject(forked.getObject());
references.createReference(forkRepositoryId, createPullRequestBranch);
// create a file for our Pull Request
Map<String, String> content = new HashMap<>();
content.put("message", "We added some content for " + count);
content.put("content", "bXkgbmV3IGZpbGUgY29udGVudHM=");
content.put("branch", "pull-" + count);
rest.put("https://api.github.com/repos/{owner}/{repo}/contents/forPullRequest?access_token={token}", content, user.getGitHubUsername(), "cla-test", user.getGitHubAccessToken());
PullRequest request = new PullRequest();
request.setTitle("Please merge");
request.setBody("Please merge");
PullRequestMarker head = new PullRequestMarker();
head.setLabel(signUser.getGitHubUsername() + ":pull-" + count);
request.setHead(head);
PullRequestMarker base = new PullRequestMarker();
base.setLabel("master");
request.setBase(base);
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
PullRequest newPull = pulls.createPullRequest(RepositoryId.createFromId(linkUser.getGitHubUsername() + "/" + "cla-test"), request);
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
return newPull.getHtmlUrl();
}
Aggregations