Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/main/java/org/gitlab4j/api/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<SquashOption> 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 {

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/gitlab4j/api/ImportExportApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/gitlab4j/api/ProjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/gitlab4j/api/models/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}