/** * Delete commit comment with given id from given repository * * @param repository * @param commentId * @throws IOException */ public void deleteComment(IRepositoryIdProvider repository, long commentId) throws IOException { String id = getId(repository); StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COMMENTS); uri.append('/').append(commentId); client.delete(uri.toString()); }
/** * Edit given comment * * @param repository * @param comment * @return edited comment * @throws IOException */ public CommitComment editComment(IRepositoryIdProvider repository, CommitComment comment) throws IOException { String id = getId(repository); if (comment == null) throw new IllegalArgumentException("Comment cannot be null"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COMMENTS); uri.append('/').append(comment.getId()); return client.post(uri.toString(), comment, CommitComment.class); }
/** * Add comment to given commit * * @param repository * @param sha * @param comment * @return created comment * @throws IOException */ public CommitComment addComment(IRepositoryIdProvider repository, String sha, CommitComment comment) throws IOException { String id = getId(repository); if (sha == null) throw new IllegalArgumentException("Sha cannot be null"); //$NON-NLS-1$ if (sha.length() == 0) throw new IllegalArgumentException("Sha cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COMMITS); uri.append('/').append(sha); uri.append(SEGMENT_COMMENTS); return client.post(uri.toString(), comment, CommitComment.class); }
/** * Get statuses for commit SHA-1 * * @param repository * @param sha * @return list of statuses * @throws IOException */ public List<CommitStatus> getStatuses(IRepositoryIdProvider repository, String sha) throws IOException { String id = getId(repository); if (sha == null) throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$ if (sha.length() == 0) throw new IllegalArgumentException("SHA-1 cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_STATUSES); uri.append('/').append(sha); PagedRequest<CommitStatus> request = createPagedRequest(); request.setType(new TypeToken<List<CommitStatus>>() { }.getType()); request.setUri(uri); return getAll(request); }
/** * Compare base and head commits * * @param repository * @param base * @param head * @return commit compare * @throws IOException */ public RepositoryCommitCompare compare(IRepositoryIdProvider repository, String base, String head) throws IOException { String id = getId(repository); if (base == null) throw new IllegalArgumentException("Base cannot be null"); //$NON-NLS-1$ if (base.length() == 0) throw new IllegalArgumentException("Base cannot be empty"); //$NON-NLS-1$ if (head == null) throw new IllegalArgumentException("Head cannot be null"); //$NON-NLS-1$ if (head.length() == 0) throw new IllegalArgumentException("Head cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COMPARE); uri.append('/').append(base).append("...").append(head); //$NON-NLS-1$ GitHubRequest request = createRequest(); request.setType(RepositoryCommitCompare.class); request.setUri(uri); return (RepositoryCommitCompare) client.get(request).getBody(); }
/** * Get commit with given SHA-1 from given repository * * @param repository * @param sha * @return repository commit * @throws IOException */ public RepositoryCommit getCommit(IRepositoryIdProvider repository, String sha) throws IOException { String id = getId(repository); if (sha == null) throw new IllegalArgumentException("Sha cannot be null"); //$NON-NLS-1$ if (sha.length() == 0) throw new IllegalArgumentException("Sha cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COMMITS); uri.append('/').append(sha); GitHubRequest request = createRequest(); request.setUri(uri); request.setType(RepositoryCommit.class); return (RepositoryCommit) client.get(request).getBody(); }
/** * Get commit comment with given id * * @param repository * @param commentId * @return commit comment * @throws IOException */ public CommitComment getComment(IRepositoryIdProvider repository, long commentId) throws IOException { String repoId = getId(repository); StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(repoId); uri.append(SEGMENT_COMMENTS); uri.append('/').append(commentId); GitHubRequest request = createRequest(); request.setUri(uri); request.setType(CommitComment.class); return (CommitComment) client.get(request).getBody(); }
/** * Page comments on commit with given SHA-1 * * @param repository * @param sha * @param start * @param size * @return page iterator over comments */ public PageIterator<CommitComment> pageComments( IRepositoryIdProvider repository, String sha, int start, int size) { String id = getId(repository); if (sha == null) throw new IllegalArgumentException("Sha cannot be null"); //$NON-NLS-1$ if (sha.length() == 0) throw new IllegalArgumentException("Sha cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COMMITS); uri.append('/').append(sha); uri.append(SEGMENT_COMMENTS); PagedRequest<CommitComment> request = createPagedRequest(start, size); request.setUri(uri); request.setType(new TypeToken<List<CommitComment>>() { }.getType()); return createPageIterator(request); }
String id = getId(repository); if (sha == null) throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$
/** * Page all comments on all commits in the given repository * * @param repository * @param start * @param size * @return page iterator over comments */ public PageIterator<CommitComment> pageComments( IRepositoryIdProvider repository, int start, int size) { String id = getId(repository); StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COMMENTS); PagedRequest<CommitComment> request = createPagedRequest(start, size); request.setUri(uri); request.setType(new TypeToken<List<CommitComment>>() { }.getType()); return createPageIterator(request); } }
/** * Page commits in given repository * * @param repository * @param sha * @param path * @param size * @return page iterator */ public PageIterator<RepositoryCommit> pageCommits( IRepositoryIdProvider repository, String sha, String path, int size) { String id = getId(repository); StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COMMITS); PagedRequest<RepositoryCommit> request = createPagedRequest(PAGE_FIRST, size); request.setUri(uri); request.setType(new TypeToken<List<RepositoryCommit>>() { }.getType()); if (sha != null || path != null) { Map<String, String> params = new HashMap<String, String>(); if (sha != null) params.put("sha", sha); //$NON-NLS-1$ if (path != null) params.put("path", path); //$NON-NLS-1$ request.setParams(params); } return createPageIterator(request); }