diff --git a/src/main/java/org/gitlab4j/api/Constants.java b/src/main/java/org/gitlab4j/api/Constants.java index 175f4eeee..a627b1361 100644 --- a/src/main/java/org/gitlab4j/api/Constants.java +++ b/src/main/java/org/gitlab4j/api/Constants.java @@ -850,6 +850,29 @@ public String toString() { } } + /** Enum for the build_git_strategy of the project instance. */ + enum SquashOption { + + NEVER, ALWAYS, DEFAULT_ON, DEFAULT_OFF; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SquashOption.class); + + @JsonCreator + public static SquashOption forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + /** Enum for the build_git_strategy of the project instance. */ enum BuildGitStrategy { diff --git a/src/main/java/org/gitlab4j/api/ImportExportApi.java b/src/main/java/org/gitlab4j/api/ImportExportApi.java index 2a3573245..33a233dde 100644 --- a/src/main/java/org/gitlab4j/api/ImportExportApi.java +++ b/src/main/java/org/gitlab4j/api/ImportExportApi.java @@ -238,7 +238,8 @@ public ImportStatus startImport(Object namespaceIdOrPath, File exportFile, Strin .withParam("initialize_with_readme", overrideParams.getInitializeWithReadme()) .withParam("packages_enabled", overrideParams.getPackagesEnabled()) .withParam("build_git_strategy", overrideParams.getBuildGitStrategy()) - .withParam("build_coverage_regex", overrideParams.getBuildCoverageRegex()); + .withParam("build_coverage_regex", overrideParams.getBuildCoverageRegex()) + .withParam("squash_option", overrideParams.getSquashOption()); } Response response = upload(Response.Status.CREATED, "file", exportFile, null, formData, url); diff --git a/src/main/java/org/gitlab4j/api/ProjectApi.java b/src/main/java/org/gitlab4j/api/ProjectApi.java index 94b719196..bcfeaa81a 100644 --- a/src/main/java/org/gitlab4j/api/ProjectApi.java +++ b/src/main/java/org/gitlab4j/api/ProjectApi.java @@ -924,7 +924,7 @@ public Project createProject(String projectName) throws GitLabApiException { * @throws GitLabApiException if any exception occurs */ public Project createProject(String name, String path) throws GitLabApiException { - + if ((name == null || name.trim().isEmpty()) && (path == null || path.trim().isEmpty())) { throw new RuntimeException("Either name or path must be specified."); } @@ -976,6 +976,7 @@ public Project createProject(Project project) throws GitLabApiException { * packagesEnabled (optional) - Enable or disable mvn packages repository feature * buildGitStrategy (optional) - set the build git strategy * buildCoverageRegex (optional) - set build coverage regex + * squashOption (optional) - set squash option for merge requests * * @param project the Project instance with the configuration for the new project * @param importUrl the URL to import the repository from @@ -1024,7 +1025,8 @@ public Project createProject(Project project, String importUrl) throws GitLabApi .withParam("build_git_strategy", project.getBuildGitStrategy()) .withParam("build_coverage_regex", project.getBuildCoverageRegex()) .withParam("suggestion_commit_message", project.getSuggestionCommitMessage()) - .withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge()); + .withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge()) + .withParam("squash_option", project.getSquashOption()); Namespace namespace = project.getNamespace(); if (namespace != null && namespace.getId() != null) { @@ -1222,6 +1224,7 @@ public Project createProject(String name, Integer namespaceId, String descriptio * packagesEnabled (optional) - Enable or disable mvn packages repository feature * buildGitStrategy (optional) - set the build git strategy * buildCoverageRegex (optional) - set build coverage regex + * squashOption (optional) - set squash option for merge requests * * NOTE: The following parameters specified by the GitLab API edit project are not supported: * import_url @@ -1270,7 +1273,8 @@ public Project updateProject(Project project) throws GitLabApiException { .withParam("build_coverage_regex", project.getBuildCoverageRegex()) .withParam("merge_method", project.getMergeMethod()) .withParam("suggestion_commit_message", project.getSuggestionCommitMessage()) - .withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge()); + .withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge()) + .withParam("squash_option", project.getSquashOption()); if (isApiVersion(ApiVersion.V3)) { formData.withParam("visibility_level", project.getVisibilityLevel()); diff --git a/src/main/java/org/gitlab4j/api/models/Project.java b/src/main/java/org/gitlab4j/api/models/Project.java index 9f101fcfb..abbce6b58 100644 --- a/src/main/java/org/gitlab4j/api/models/Project.java +++ b/src/main/java/org/gitlab4j/api/models/Project.java @@ -6,6 +6,7 @@ import org.gitlab4j.api.Constants.AutoDevopsDeployStrategy; import org.gitlab4j.api.Constants.BuildGitStrategy; +import org.gitlab4j.api.Constants.SquashOption; import org.gitlab4j.api.ProjectLicense; import org.gitlab4j.api.models.ImportStatus.Status; import org.gitlab4j.api.utils.JacksonJson; @@ -105,6 +106,7 @@ public String toString() { private Boolean autocloseReferencedIssues; private Boolean emailsDisabled; private String suggestionCommitMessage; + private SquashOption squashOption; @JsonSerialize(using = JacksonJson.DateOnlySerializer.class) private Date markedForDeletionOn; @@ -842,4 +844,17 @@ public Project withSuggestionCommitMessage(String suggestionCommitMessage) { public void setSuggestionCommitMessage(String suggestionCommitMessage) { this.suggestionCommitMessage = suggestionCommitMessage; } + + public SquashOption getSquashOption() { + return squashOption; + } + + public void setSquashOption(SquashOption squashOption) { + this.squashOption = squashOption; + } + + public Project withSquashOption(SquashOption squashOption) { + this.squashOption = squashOption; + return this; + } }