From 575045c536135ac4a5ccf90008c43eb00a563665 Mon Sep 17 00:00:00 2001 From: Greg Messner Date: Thu, 4 Apr 2019 17:15:50 -0700 Subject: [PATCH] Added compare() method that takes a straight parameter (#322). --- .../java/org/gitlab4j/api/RepositoryApi.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/RepositoryApi.java b/src/main/java/org/gitlab4j/api/RepositoryApi.java index b17c571c..48c985a3 100644 --- a/src/main/java/org/gitlab4j/api/RepositoryApi.java +++ b/src/main/java/org/gitlab4j/api/RepositoryApi.java @@ -676,16 +676,35 @@ public class RepositoryApi extends AbstractApi { * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param from the commit SHA or branch name * @param to the commit SHA or branch name + * @param straight specifies the comparison method, true for direct comparison between from and to (from..to), + * false to compare using merge base (from…to)’. * @return a CompareResults containing the results of the comparison * @throws GitLabApiException if any exception occurs */ - public CompareResults compare(Object projectIdOrPath, String from, String to) throws GitLabApiException { - Form formData = new GitLabApiForm().withParam("from", from, true).withParam("to", to, true); + public CompareResults compare(Object projectIdOrPath, String from, String to, boolean straight) throws GitLabApiException { + Form formData = new GitLabApiForm() + .withParam("from", from, true) + .withParam("to", to, true) + .withParam("straight", straight); Response response = get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "compare"); return (response.readEntity(CompareResults.class)); } + /** + * Compare branches, tags or commits. This can be accessed without authentication + * if the repository is publicly accessible. + * + * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance + * @param from the commit SHA or branch name + * @param to the commit SHA or branch name + * @return a CompareResults containing the results of the comparison + * @throws GitLabApiException if any exception occurs + */ + public CompareResults compare(Object projectIdOrPath, String from, String to) throws GitLabApiException { + return (compare(projectIdOrPath, from, to, false)); + } + /** * Get a list of contributors from a project. * -- GitLab