Commit a913a19b authored by Greg Messner's avatar Greg Messner
Browse files

Added a few merge request related calls.

parent ba09289c
...@@ -141,11 +141,12 @@ public class GitLabApi { ...@@ -141,11 +141,12 @@ public class GitLabApi {
* @param sourceBranch the source branch, required * @param sourceBranch the source branch, required
* @param targetBranch the target branch, required * @param targetBranch the target branch, required
* @param title the title for the merge request, required * @param title the title for the merge request, required
* @param description the description of the merge request
* @param assigneeId the Assignee user ID, optional * @param assigneeId the Assignee user ID, optional
* @return the created MergeRequest instance * @return the created MergeRequest instance
* @throws IOException * @throws IOException
*/ */
public MergeRequest createMergeRequest (Integer projectId, String sourceBranch, String targetBranch, String title, Integer assigneeId) public MergeRequest createMergeRequest (Integer projectId, String sourceBranch, String targetBranch, String title, String description, Integer assigneeId)
throws IOException { throws IOException {
/* /*
...@@ -161,16 +162,19 @@ public class GitLabApi { ...@@ -161,16 +162,19 @@ public class GitLabApi {
} }
Form formData = new Form(); Form formData = new Form();
formData.add("id", projectId);
formData.add("source_branch", sourceBranch); formData.add("source_branch", sourceBranch);
formData.add("target_branch", targetBranch); formData.add("target_branch", targetBranch);
formData.add("title", title); formData.add("title", title);
if (description != null) {
formData.add("description", description);
}
if (assigneeId != null) { if (assigneeId != null) {
formData.add("assignee_id", assigneeId); formData.add("assignee_id", assigneeId);
} }
ClientResponse response = apiClient.post(formData, "projects", projectId, "merge-requests"); ClientResponse response = apiClient.post(formData, "projects", projectId, "merge_requests");
if (response.getStatus() != ClientResponse.Status.CREATED.getStatusCode()) { if (response.getStatus() != ClientResponse.Status.CREATED.getStatusCode()) {
ErrorMessage errorMessage = response.getEntity(ErrorMessage.class); ErrorMessage errorMessage = response.getEntity(ErrorMessage.class);
throw new RuntimeException(errorMessage.getMessage()); throw new RuntimeException(errorMessage.getMessage());
...@@ -180,6 +184,28 @@ public class GitLabApi { ...@@ -180,6 +184,28 @@ public class GitLabApi {
} }
/**
* POST /projects/:id/merge_request/:merge_request_id/comments
*
* @param projectId
* @param mergeRequestId
* @param comments
* @throws IOException
*/
public MergeRequestComment addMergeRequestComment (Integer projectId, Integer mergeRequestId, String comments) throws IOException {
Form formData = new Form();
formData.add("note", comments);
ClientResponse response = apiClient.post(formData, "projects", projectId, "merge_request", mergeRequestId, "comments");
if (response.getStatus() != ClientResponse.Status.CREATED.getStatusCode()) {
ErrorMessage errorMessage = response.getEntity(ErrorMessage.class);
throw new RuntimeException(errorMessage.getMessage());
}
return (response.getEntity(MergeRequestComment.class));
}
/** /**
* GET /projects/:id/repository/branches/:branch * GET /projects/:id/repository/branches/:branch
* *
...@@ -191,7 +217,20 @@ public class GitLabApi { ...@@ -191,7 +217,20 @@ public class GitLabApi {
public Branch getBranch (Integer projectId, String branchName) throws IOException { public Branch getBranch (Integer projectId, String branchName) throws IOException {
ClientResponse response = apiClient.get(null, "projects", projectId, "repository", "branches", branchName); ClientResponse response = apiClient.get(null, "projects", projectId, "repository", "branches", branchName);
return (response.getEntity(Branch.class)); return (response.getEntity(Branch.class));
} }
/**
* GET /projects/:id/repository/commits/branch
*
* @param branch
* @return
*/
public List<Commit> getCommits (int projectId, String branch) throws IOException {
ClientResponse response = apiClient.get(null, "projects", projectId, "repository", "commits", branch);
return (response.getEntity(new GenericType<List<Commit>>() {}));
}
/** /**
* GET /users/:id * GET /users/:id
......
Supports Markdown
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