Commit 6f32f141 authored by Christopher Luu's avatar Christopher Luu

Added authors to commits. Added commit diffs and fetching of them.

parent 5d43fbe5
......@@ -4,6 +4,7 @@ import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.gitlab.api.http.GitlabHTTPRequestor;
import org.gitlab.api.models.GitlabCommit;
import org.gitlab.api.models.GitlabCommitDiff;
import org.gitlab.api.models.GitlabMergeRequest;
import org.gitlab.api.models.GitlabNote;
import org.gitlab.api.models.GitlabProject;
......@@ -245,6 +246,14 @@ public class GitlabAPI {
return Arrays.asList(commits);
}
// List commit diffs for a project ID and commit hash
// GET /projects/:id/repository/commits/:sha/diff
public List<GitlabCommitDiff> getCommitDiffs(String projectId, String commitHash) throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + "/repository/commits/" + commitHash + GitlabCommitDiff.URL;
GitlabCommitDiff[] diffs = retrieve().to(tailUrl, GitlabCommitDiff[].class);
return Arrays.asList(diffs);
}
/*
User APIs
http://api.gitlab.org/users.html
......
package org.gitlab.api.models;
import java.util.Date;
import java.util.List;
import org.codehaus.jackson.annotate.JsonProperty;
public class GitlabCommit {
......@@ -22,6 +23,9 @@ public class GitlabCommit {
@JsonProperty("created_at")
private Date _createdAt;
@JsonProperty("parent_ids")
private List<String> _parentIds;
public String getId() {
return _id;
}
......@@ -69,4 +73,12 @@ public class GitlabCommit {
public void setCreatedAt(Date createdAt) {
_createdAt = createdAt;
}
public List<String> getParentIds() {
return _parentIds;
}
public void setParentIds(List<String> parentIds) {
_parentIds = parentIds;
}
}
package org.gitlab.api.models;
import org.codehaus.jackson.annotate.JsonProperty;
public class GitlabCommitDiff {
public final static String URL = "/diff";
@JsonProperty("diff")
private String _diff;
@JsonProperty("new_path")
private String _newPath;
@JsonProperty("old_path")
private String _oldPath;
@JsonProperty("a_mode")
private String _aMode;
@JsonProperty("b_mode")
private String _bMode;
@JsonProperty("new_file")
private boolean _newFile;
@JsonProperty("renamed_file")
private boolean _renamedFile;
@JsonProperty("deleted_file")
private boolean _deletedFile;
public String getDiff() {
return _diff;
}
public void setDiff(String diff) {
_diff = diff;
}
public String getNewPath() {
return _newPath;
}
public void setNewPath(String newPath) {
_newPath = newPath;
}
public String getOldPath() {
return _oldPath;
}
public void setOldPath(String oldPath) {
_oldPath = oldPath;
}
public String getAMode() {
return _aMode;
}
public void setAMode(String aMode) {
_aMode = aMode;
}
public String getBMode() {
return _bMode;
}
public void setBMode(String bMode) {
_bMode = bMode;
}
public boolean getNewFile() {
return _newFile;
}
public void setNewFile(boolean newFile) {
_newFile = newFile;
}
public boolean getRenamedFile() {
return _renamedFile;
}
public void setRenamedFile(boolean renamedFile) {
_renamedFile = renamedFile;
}
public boolean getDeletedFile() {
return _deletedFile;
}
public void setDeletedFile(boolean deletedFile) {
_deletedFile = deletedFile;
}
}
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