private Vertex savePullRequestMarker(final PullRequestMarker head) { Vertex markernode = getOrCreatePullRequestMarker(head); setProperty(markernode, PropertyName.LABEL, head.getLabel()); setProperty(markernode, PropertyName.SHA, head.getSha()); setProperty(markernode, PropertyName.REF, head.getRef()); User user = head.getUser(); if (user != null) { Vertex usernode = saveUser(user); createEdgeIfNotExist(markernode, usernode, EdgeType.PULLREQUESTMARKERUSER); } Repository repo = head.getRepo(); if (repo != null) { Vertex reponode = saveRepository(repo); createEdgeIfNotExist(markernode, reponode, EdgeType.REPOSITORY); } return markernode; }
private boolean matchPullRequest(String base, String head, PullRequest openPR) { boolean matchingHead = head.equals(openPR.getHead().getLabel()); String openmrsBase = base.startsWith(OPENMRS_USER) ? base : OPENMRS_USER+":"+base; boolean matchingBase = openmrsBase.equals(openPR.getBase().getLabel()); return matchingBase && matchingHead; }
private Vertex getOrCreatePullRequestMarker(final PullRequestMarker head) { return getOrCreateVertexHelper(IdCols.PULLREQUESTMARKER, head.getSha(), VertexType.PULLREQUESTMARKER, markeridx); }
/** * @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 Map<String, String> createPrMap(PullRequest request) { Map<String, String> params = new HashMap<String, String>(); if (request != null) { String title = request.getTitle(); if (title != null) params.put(PR_TITLE, title); String body = request.getBody(); if (body != null) params.put(PR_BODY, body); PullRequestMarker baseMarker = request.getBase(); if (baseMarker != null) { String base = baseMarker.getLabel(); if (base != null) params.put(PR_BASE, base); } PullRequestMarker headMarker = request.getHead(); if (headMarker != null) { String head = headMarker.getLabel(); if (head != null) params.put(PR_HEAD, head); } } return params; }
e.getIn().setHeader(GitHubConstants.GITHUB_PULLREQUEST_HEAD_COMMIT_SHA, newPullRequest.getHead().getSha());