Commit 55bfa575 authored by Tyler Rockwood's avatar Tyler Rockwood

Added ability to compare commits

parent 7f81faff
......@@ -1022,6 +1022,24 @@ public class GitlabAPI {
return Arrays.asList(diffs);
}
// List commit diffs for a project ID and two commit hashes
// GET /projects/:id/repository/compare
public GitlabCommitComparison compareCommits(Serializable projectId, String commitHash1, String commitHash2) throws IOException {
return compareCommits(projectId, commitHash1, commitHash2, new Pagination());
}
// List commit diffs for a project ID and two commit hashes
// GET /projects/:id/repository/compare
public GitlabCommitComparison compareCommits(Serializable projectId, String commitHash1, String commitHash2, Pagination pagination) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabCommitComparison.URL;
Query query = new Query()
.append("from", commitHash1)
.append("to", commitHash2);
query.mergeWith(pagination.asQuery());
return retrieve().to(tailUrl + query, GitlabCommitComparison.class);
}
// List commit statuses for a project ID and commit hash
// GET /projects/:id/repository/commits/:sha/statuses
public List<GitlabCommitStatus> getCommitStatuses(GitlabProject project, String commitHash) throws IOException {
......
package org.gitlab.api.models;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
public class GitlabCommitComparison {
public final static String URL = "/repository/compare";
@JsonProperty("commit")
private GitlabCommit commit;
@JsonProperty("commits")
private List<GitlabCommit> commits;
@JsonProperty("diffs")
private List<GitlabCommitDiff> diffs;
@JsonProperty("compare_same_ref")
private Boolean compareSameRef;
@JsonProperty("compare_timeout")
private Boolean compareTimeout;
public GitlabCommit getCommit() {
return commit;
}
public void setCommit(GitlabCommit commit) {
this.commit = commit;
}
public List<GitlabCommit> getCommits() {
return commits;
}
public void setCommits(List<GitlabCommit> commits) {
this.commits = commits;
}
public List<GitlabCommitDiff> getDiffs() {
return diffs;
}
public void setDiffs(List<GitlabCommitDiff> diffs) {
this.diffs = diffs;
}
public Boolean getCompareSameRef() {
return compareSameRef;
}
public void setCompareSameRef(Boolean compareSameRef) {
this.compareSameRef = compareSameRef;
}
public Boolean getCompareTimeout() {
return compareTimeout;
}
public void setCompareTimeout(Boolean compareTimeout) {
this.compareTimeout = compareTimeout;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment