diff --git a/pom.xml b/pom.xml
index ab24b40d..0a814c1a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.gitlab
java-gitlab-api
- 4.0.1-SNAPSHOT
+ 4.0.1.smartbear.8.2
Gitlab Java API Wrapper
A Java wrapper for the Gitlab Git Hosting Server API
diff --git a/src/main/java/org/gitlab/api/GitlabAPI.java b/src/main/java/org/gitlab/api/GitlabAPI.java
index a9806d23..73ebe715 100644
--- a/src/main/java/org/gitlab/api/GitlabAPI.java
+++ b/src/main/java/org/gitlab/api/GitlabAPI.java
@@ -1252,22 +1252,22 @@ public List getMergeRequestsWithStatus(GitlabProject project
return retrieve().getAll(tailUrl, GitlabMergeRequest[].class);
}
- public List getMergeRequests(Serializable projectId) throws IOException {
+ public List getMergeRequests(Serializable projectId) {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabMergeRequest.URL + PARAM_MAX_ITEMS_PER_PAGE;
return retrieve().getAll(tailUrl, GitlabMergeRequest[].class);
}
- public List getMergeRequests(Serializable projectId, Pagination pagination) throws IOException {
+ public List getMergeRequests(Serializable projectId, Pagination pagination) {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabMergeRequest.URL + pagination.toString();
return retrieve().getAll(tailUrl, GitlabMergeRequest[].class);
}
- public List getMergeRequests(GitlabProject project) throws IOException {
+ public List getMergeRequests(GitlabProject project) {
String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabMergeRequest.URL + PARAM_MAX_ITEMS_PER_PAGE;
return retrieve().getAll(tailUrl, GitlabMergeRequest[].class);
}
- public List getMergeRequests(GitlabProject project, Pagination pagination) throws IOException {
+ public List getMergeRequests(GitlabProject project, Pagination pagination) {
String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabMergeRequest.URL + pagination.toString();
return retrieve().getAll(tailUrl, GitlabMergeRequest[].class);
}
@@ -1332,11 +1332,19 @@ public GitlabMergeRequest getMergeRequestChanges(Serializable projectId, Integer
return retrieve().to(tailUrl, GitlabMergeRequest.class);
}
- public GitlabMergeRequest getMergeRequest(GitlabProject project, Integer mergeRequestId) throws IOException {
- String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabMergeRequest.URL + "/" + mergeRequestId;
+ public List getMergeRequestCommits(Serializable projectId, Integer mergeRequestId) {
+ String tailUrl = "/projects/" + this.sanitizeProjectId(projectId) + "/merge_requests" + "/" + mergeRequestId + "/commits";
+ return this.retrieve().getAll(tailUrl, GitlabCommit[].class);
+ }
+
+ public GitlabMergeRequest getMergeRequest(Serializable projectId, Integer mergeRequestId) throws IOException {
+ String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabMergeRequest.URL + "/" + mergeRequestId;
return retrieve().to(tailUrl, GitlabMergeRequest.class);
}
-
+
+ public GitlabMergeRequest getMergeRequest(GitlabProject project, Integer mergeRequestId) throws IOException {
+ return getMergeRequest(project.getId(), mergeRequestId);
+ }
/**
* Create a new MergeRequest
@@ -1401,13 +1409,26 @@ public GitlabMergeRequest updateMergeRequest(Serializable projectId, Integer mer
* @return new merge request status
* @throws IOException on gitlab api call error
*/
- public GitlabMergeRequest acceptMergeRequest(GitlabProject project, Integer mergeRequestId, String mergeCommitMessage) throws IOException {
- String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabMergeRequest.URL + "/" + mergeRequestId + "/merge";
+ public GitlabMergeRequest acceptMergeRequest(GitlabProject project, Integer mergeRequestId, String mergeCommitMessage,
+ String squashCommitMessage, boolean deleteBranch) throws IOException {
+ return acceptMergeRequest(project.getId(), mergeRequestId, mergeCommitMessage, squashCommitMessage, deleteBranch);
+ }
+
+ public GitlabMergeRequest acceptMergeRequest(Serializable projectId, Integer mergeRequestId, String mergeCommitMessage,
+ String squashCommitMessage, boolean deleteBranch) throws IOException {
+
+ String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabMergeRequest.URL + "/" + mergeRequestId + "/merge";
GitlabHTTPRequestor requestor = retrieve().method("PUT");
- requestor.with("id", project.getId());
+ requestor.with("id", projectId);
requestor.with("merge_request_id", mergeRequestId);
- if (mergeCommitMessage != null)
+ if (mergeCommitMessage != null) {
requestor.with("merge_commit_message", mergeCommitMessage);
+ }
+ if (squashCommitMessage != null) {
+ requestor.with("squash", true);
+ requestor.with("squash_commit_message", squashCommitMessage);
+ }
+ requestor.with("should_remove_source_branch", deleteBranch);
return requestor.to(tailUrl, GitlabMergeRequest.class);
}
@@ -1483,11 +1504,18 @@ public List getLastCommits(Serializable projectId, String branchOr
public List getCommits(Serializable projectId, Pagination pagination,
String branchOrTag) throws IOException {
+ return getCommits(projectId, null, branchOrTag, null);
+ }
+
+ public List getCommits(Serializable projectId, Pagination pagination,
+ String branchOrTag, String path) throws IOException {
final Query query = new Query();
if (branchOrTag != null) {
query.append("ref_name", branchOrTag);
}
-
+ if (path != null) {
+ query.append("path", path);
+ }
if (pagination != null) {
query.mergeWith(pagination.asQuery());
}
@@ -1559,12 +1587,21 @@ public GitlabCommitComparison compareCommits(Serializable projectId, String comm
// List commit statuses for a project ID and commit hash
// GET /projects/:id/repository/commits/:sha/statuses
public List getCommitStatuses(GitlabProject project, String commitHash) throws IOException {
- return getCommitStatuses(project, commitHash, new Pagination());
+ return getCommitStatuses(project.getId(), commitHash, new Pagination());
+ }
+
+ public List getCommitStatuses(Serializable projectId, String commitHash) throws IOException {
+ return getCommitStatuses(projectId, commitHash, new Pagination());
}
public List getCommitStatuses(GitlabProject project, String commitHash,
Pagination pagination) throws IOException {
- String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository" + GitlabCommit.URL + "/" +
+ return getCommitStatuses(project.getId(), commitHash, pagination);
+ }
+
+ public List getCommitStatuses(Serializable projectId, String commitHash,
+ Pagination pagination) throws IOException {
+ String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + "/repository" + GitlabCommit.URL + "/" +
commitHash + GitlabCommitStatus.URL + pagination;
GitlabCommitStatus[] statuses = retrieve().to(tailUrl, GitlabCommitStatus[].class);
return Arrays.asList(statuses);
@@ -1574,7 +1611,12 @@ public List getCommitStatuses(GitlabProject project, String
// GET /projects/:id/statuses/:sha
public GitlabCommitStatus createCommitStatus(GitlabProject project, String commitHash, String state, String ref,
String name, String targetUrl, String description) throws IOException {
- String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabCommitStatus.URL + "/" + commitHash;
+ return createCommitStatus(project.getId(), commitHash, state, ref, name, targetUrl, description);
+ }
+
+ public GitlabCommitStatus createCommitStatus(Serializable projectId, String commitHash, String state, String ref,
+ String name, String targetUrl, String description) throws IOException {
+ String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabCommitStatus.URL + "/" + commitHash;
return dispatch()
.with("state", state)
.with("ref", ref)
@@ -1604,11 +1646,11 @@ public byte[] getRawFileContent(GitlabProject project, String sha, String filepa
* @param filepath The path of the file
* @throws IOException on gitlab api call error
*/
- public byte[] getRawFileContent(Integer projectId, String sha, String filepath) throws IOException {
+ public byte[] getRawFileContent(Serializable projectId, String sha, String filepath) throws IOException {
Query query = new Query()
.append("ref", sha);
- String tailUrl = GitlabProject.URL + "/" + projectId + "/repository/files/" + sanitizePath(filepath) + "/raw" + query.toString();
+ String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + "/repository/files/" + sanitizePath(filepath) + "/raw" + query.toString();
return retrieve().to(tailUrl, byte[].class);
}
@@ -1873,7 +1915,7 @@ public GitlabProjectHook addProjectHook(GitlabProject project, String url, Strin
.to(tailUrl, GitlabProjectHook.class);
}
- public GitlabProjectHook addProjectHook(Serializable projectId, String url, boolean pushEvents, boolean issuesEvents, boolean mergeRequestEvents, boolean tagPushEvents, boolean sslVerification) throws IOException {
+ public GitlabProjectHook addProjectHook(Serializable projectId, String url, boolean pushEvents, boolean issuesEvents, boolean mergeRequestEvents, boolean noteEvents, boolean tagPushEvents, boolean sslVerification, String token) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabProjectHook.URL;
return dispatch()
@@ -1881,8 +1923,37 @@ public GitlabProjectHook addProjectHook(Serializable projectId, String url, bool
.with("push_events", pushEvents ? "true" : "false")
.with("issues_events", issuesEvents ? "true" : "false")
.with("merge_requests_events", mergeRequestEvents ? "true" : "false")
+ .with("note_events", noteEvents ? "true" : "false")
.with("tag_push_events", tagPushEvents ? "true" : "false")
.with("enable_ssl_verification", sslVerification ? "true" : "false")
+ .with("token", token)
+ .to(tailUrl, GitlabProjectHook.class);
+ }
+
+ public GitlabProjectHook addProjectHook(Serializable projectId,
+ String url,
+ boolean pushEvents,
+ boolean issuesEvents,
+ boolean mergeRequestEvents,
+ boolean noteEvents,
+ boolean tagPushEvents,
+ boolean sslVerification,
+ boolean jobEvents,
+ boolean pipelineEvents,
+ String token) throws IOException {
+ String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabProjectHook.URL;
+
+ return dispatch()
+ .with("url", url)
+ .with("push_events", pushEvents ? "true" : "false")
+ .with("issues_events", issuesEvents ? "true" : "false")
+ .with("merge_requests_events", mergeRequestEvents ? "true" : "false")
+ .with("note_events", noteEvents ? "true" : "false")
+ .with("tag_push_events", tagPushEvents ? "true" : "false")
+ .with("enable_ssl_verification", sslVerification ? "true" : "false")
+ .with("pipeline_events", pipelineEvents ? "true" : "false")
+ .with("job_events", jobEvents ? "true" : "false")
+ .with("token", token)
.to(tailUrl, GitlabProjectHook.class);
}
@@ -2368,6 +2439,15 @@ public List getProjectMembers(Serializable projectId, Pagin
return Arrays.asList(retrieve().to(tailUrl, GitlabProjectMember[].class));
}
+ public List getProjectMembersAll(Serializable projectId) throws IOException {
+ return getProjectMembersAll(projectId, new Pagination());
+ }
+
+ public List getProjectMembersAll(Serializable projectId, Pagination pagination) throws IOException {
+ String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabProjectMember.URL + "/all" + pagination.asQuery();
+ return Arrays.asList(retrieve().to(tailUrl, GitlabProjectMember[].class));
+ }
+
/**
* This will fail, if the given namespace is a user and not a group
*
@@ -2538,7 +2618,7 @@ private String sanitizeId(Serializable id, String parameterName) {
private String sanitizePath(String branch) {
try {
- return URLEncoder.encode(branch, "UTF-8");
+ return URLEncoder.encode(branch, "UTF-8").replaceAll("\\+", "%20");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException((e));
}
@@ -2557,7 +2637,7 @@ private String sanitizePath(String branch) {
* @throws IOException on gitlab api call error
* @see http://doc.gitlab.com/ce/api/commits.html#post-comment-to-commit
*/
- public CommitComment createCommitComment(Integer projectId, String sha, String note,
+ public CommitComment createCommitComment(Serializable projectId, String sha, String note,
String path, String line, String line_type) throws IOException {
Query query = new Query()
@@ -3005,6 +3085,11 @@ public List getPipelineTriggers(GitlabProject project) throws IOE
}
}
+ public List getMergeRequestPipelines(Serializable projectName, Integer mergeRequestId) throws IOException {
+ return retrieve().getAll(GitlabProject.URL + "/" + sanitizeProjectId(projectName) + GitlabMergeRequest.URL + "/"
+ + mergeRequestId + GitlabPipeline.URL + PARAM_MAX_ITEMS_PER_PAGE, GitlabPipeline[].class);
+ }
+
/**
* Gets email-on-push service setup for a projectId.
*
diff --git a/src/main/java/org/gitlab/api/models/GitlabMergeRequest.java b/src/main/java/org/gitlab/api/models/GitlabMergeRequest.java
index 7663af17..d90f05bd 100644
--- a/src/main/java/org/gitlab/api/models/GitlabMergeRequest.java
+++ b/src/main/java/org/gitlab/api/models/GitlabMergeRequest.java
@@ -64,6 +64,15 @@ public class GitlabMergeRequest {
@JsonProperty("sha")
private String sha;
+ @JsonProperty("has_conflicts")
+ private boolean hasConflicts;
+
+ @JsonProperty
+ private boolean squash;
+
+ @JsonProperty("force_remove_source_branch")
+ private boolean forceRemoveSourceBranch;
+
public Integer getId() {
return id;
}
@@ -281,4 +290,28 @@ public String getSha() {
public void setSha(String sha) {
this.sha = sha;
}
+
+ public boolean isHasConflicts() {
+ return hasConflicts;
+ }
+
+ public void setHasConflicts(boolean hasConflicts) {
+ this.hasConflicts = hasConflicts;
+ }
+
+ public boolean isSquash() {
+ return squash;
+ }
+
+ public void setSquash(boolean squash) {
+ this.squash = squash;
+ }
+
+ public boolean isForceRemoveSourceBranch() {
+ return forceRemoveSourceBranch;
+ }
+
+ public void setForceRemoveSourceBranch(boolean forceRemoveSourceBranch) {
+ this.forceRemoveSourceBranch = forceRemoveSourceBranch;
+ }
}
diff --git a/src/main/java/org/gitlab/api/models/GitlabProject.java b/src/main/java/org/gitlab/api/models/GitlabProject.java
index 33fb923c..8c5808a6 100644
--- a/src/main/java/org/gitlab/api/models/GitlabProject.java
+++ b/src/main/java/org/gitlab/api/models/GitlabProject.java
@@ -36,6 +36,12 @@ public class GitlabProject {
@JsonProperty("merge_requests_enabled")
private Boolean mergeRequestsEnabled;
+ @JsonProperty("merge_method")
+ private String mergeMethod;
+
+ @JsonProperty("squash_option")
+ private String squashOption;
+
@JsonProperty("snippets_enabled")
private Boolean snippetsEnabled;
@@ -472,6 +478,22 @@ public void setPrintingMergeRequestLinkEnabled(Boolean printingMergeRequestLinkE
this.printingMergeRequestLinkEnabled = printingMergeRequestLinkEnabled;
}
+ public String getMergeMethod() {
+ return mergeMethod;
+ }
+
+ public void setMergeMethod(String mergeMethod) {
+ this.mergeMethod = mergeMethod;
+ }
+
+ public String getSquashOption() {
+ return squashOption;
+ }
+
+ public void setSquashOption(String squashOption) {
+ this.squashOption = squashOption;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;