Skip to content

Commit dce1deb

Browse files
committed
forkProject() now looks for CREATED status (#107).
1 parent 5e7248d commit dce1deb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,8 @@ public void deleteProject(Project project) throws GitLabApiException {
832832

833833
/**
834834
* Forks a project into the user namespace of the authenticated user or the one provided.
835+
* The forking operation for a project is asynchronous and is completed in a background job.
836+
* The request will return immediately.
835837
*
836838
* POST /projects/:id/fork
837839
*
@@ -841,11 +843,14 @@ public void deleteProject(Project project) throws GitLabApiException {
841843
*/
842844
public void forkProject(Integer id, String namespace) throws GitLabApiException {
843845
GitLabApiForm formData = new GitLabApiForm().withParam("namespace", namespace, true);
844-
post(Response.Status.OK, formData, "projects", id, "fork");
846+
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
847+
post(expectedStatus, formData, "projects", id, "fork");
845848
}
846849

847850
/**
848851
* Forks a project into the user namespace of the authenticated user or the one provided.
852+
* The forking operation for a project is asynchronous and is completed in a background job.
853+
* The request will return immediately.
849854
*
850855
* POST /projects/:id/fork
851856
*
@@ -859,6 +864,8 @@ public void forkProject(Project project, String namespace) throws GitLabApiExcep
859864

860865
/**
861866
* Forks a project into the user namespace of the authenticated user or the one provided.
867+
* The forking operation for a project is asynchronous and is completed in a background job.
868+
* The request will return immediately.
862869
*
863870
* POST /projects/:id/fork
864871
*
@@ -868,11 +875,14 @@ public void forkProject(Project project, String namespace) throws GitLabApiExcep
868875
*/
869876
public void forkProject(Integer id, Integer namespaceId) throws GitLabApiException {
870877
GitLabApiForm formData = new GitLabApiForm().withParam("namespace", namespaceId, true);
871-
post(Response.Status.OK, formData, "projects", id, "fork");
878+
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
879+
post(expectedStatus, formData, "projects", id, "fork");
872880
}
873881

874882
/**
875883
* Forks a project into the user namespace of the authenticated user or the one provided.
884+
* The forking operation for a project is asynchronous and is completed in a background job.
885+
* The request will return immediately.
876886
*
877887
* POST /projects/:id/fork
878888
*

0 commit comments

Comments
 (0)