@@ -913,21 +913,12 @@ public File getRepositoryArchive(
913913 * false to compare using merge base (from…to)’.
914914 * @return a CompareResults containing the results of the comparison
915915 * @throws GitLabApiException if any exception occurs
916+ * @deprecated use {@link #compare(Object, String, String, Long, Boolean)} instead
916917 */
918+ @ Deprecated
917919 public CompareResults compare (Object projectIdOrPath , String from , String to , Boolean straight )
918920 throws GitLabApiException {
919- Form formData = new GitLabApiForm ()
920- .withParam ("from" , from , true )
921- .withParam ("to" , to , true )
922- .withParam ("straight" , straight );
923- Response response = get (
924- Response .Status .OK ,
925- formData .asMap (),
926- "projects" ,
927- getProjectIdOrPath (projectIdOrPath ),
928- "repository" ,
929- "compare" );
930- return (response .readEntity (CompareResults .class ));
921+ return compare (projectIdOrPath , from , to , null , straight );
931922 }
932923
933924 /**
@@ -939,9 +930,41 @@ public CompareResults compare(Object projectIdOrPath, String from, String to, Bo
939930 * @param to the commit SHA or branch name
940931 * @return a CompareResults containing the results of the comparison
941932 * @throws GitLabApiException if any exception occurs
933+ * @deprecated use {@link #compare(Object, String, String, Long, Boolean)} instead
942934 */
935+ @ Deprecated
943936 public CompareResults compare (Object projectIdOrPath , String from , String to ) throws GitLabApiException {
944- return (compare (projectIdOrPath , from , to , false ));
937+ return compare (projectIdOrPath , from , to , false );
938+ }
939+
940+ /**
941+ * Compare branches, tags or commits. This can be accessed without authentication
942+ * if the repository is publicly accessible.
943+ *
944+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
945+ * @param from the commit SHA or branch name
946+ * @param to the commit SHA or branch name
947+ * @param fromProjectId The ID to compare from.
948+ * @param straight specifies the comparison method, true for direct comparison between from and to (from..to),
949+ * false to compare using merge base (from…to)
950+ * @return a CompareResults containing the results of the comparison
951+ * @throws GitLabApiException if any exception occurs
952+ */
953+ public CompareResults compare (Object projectIdOrPath , String from , String to , Long fromProjectId , Boolean straight )
954+ throws GitLabApiException {
955+ GitLabApiForm formData = new GitLabApiForm ()
956+ .withParam ("from" , from , true )
957+ .withParam ("to" , to , true )
958+ .withParam ("straight" , straight )
959+ .withParam ("from_project_id" , fromProjectId );
960+ Response response = get (
961+ Response .Status .OK ,
962+ formData .asMap (),
963+ "projects" ,
964+ getProjectIdOrPath (projectIdOrPath ),
965+ "repository" ,
966+ "compare" );
967+ return (response .readEntity (CompareResults .class ));
945968 }
946969
947970 /**
0 commit comments