Skip to content

Commit 575045c

Browse files
committed
Added compare() method that takes a straight parameter (#322).
1 parent 9557858 commit 575045c

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/main/java/org/gitlab4j/api/RepositoryApi.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,16 +676,35 @@ public File getRepositoryArchive(Object projectIdOrPath, String sha, File direct
676676
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
677677
* @param from the commit SHA or branch name
678678
* @param to the commit SHA or branch name
679+
* @param straight specifies the comparison method, true for direct comparison between from and to (from..to),
680+
* false to compare using merge base (from…to)’.
679681
* @return a CompareResults containing the results of the comparison
680682
* @throws GitLabApiException if any exception occurs
681683
*/
682-
public CompareResults compare(Object projectIdOrPath, String from, String to) throws GitLabApiException {
683-
Form formData = new GitLabApiForm().withParam("from", from, true).withParam("to", to, true);
684+
public CompareResults compare(Object projectIdOrPath, String from, String to, boolean straight) throws GitLabApiException {
685+
Form formData = new GitLabApiForm()
686+
.withParam("from", from, true)
687+
.withParam("to", to, true)
688+
.withParam("straight", straight);
684689
Response response = get(Response.Status.OK, formData.asMap(), "projects",
685690
getProjectIdOrPath(projectIdOrPath), "repository", "compare");
686691
return (response.readEntity(CompareResults.class));
687692
}
688693

694+
/**
695+
* Compare branches, tags or commits. This can be accessed without authentication
696+
* if the repository is publicly accessible.
697+
*
698+
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
699+
* @param from the commit SHA or branch name
700+
* @param to the commit SHA or branch name
701+
* @return a CompareResults containing the results of the comparison
702+
* @throws GitLabApiException if any exception occurs
703+
*/
704+
public CompareResults compare(Object projectIdOrPath, String from, String to) throws GitLabApiException {
705+
return (compare(projectIdOrPath, from, to, false));
706+
}
707+
689708
/**
690709
* Get a list of contributors from a project.
691710
*

0 commit comments

Comments
 (0)